test multiple file upload in cucumber

This commit is contained in:
Dennis Collinson 2012-03-16 17:24:51 -07:00
parent 60420f1061
commit a0e6433f5a
2 changed files with 23 additions and 10 deletions

View file

@ -41,13 +41,23 @@ Then /^"([^"]*)" should be a (limited|public) post in my stream$/ do |post_text,
end
When /^I upload a fixture picture with filename "([^"]*)"$/ do |file_name|
orig_photo_count = all(".photos img").size
within ".new_photo" do
attach_file "photo[user_file]", Rails.root.join("spec", "fixtures", file_name)
wait_until { all(".photos img").size == orig_photo_count + 1 }
end
@image_source = find(".photos img")["src"]
@image_sources ||= {}
@image_sources[file_name] = all(".photos img").last["src"]
@image_sources[file_name].should be_present
end
Then /^"([^"]*)" should have my photo$/ do |status_text|
find_post_by_text(status_text).find(".photo_attachments img")["src"].should == @image_source
Then /^"([^"]*)" should have the "([^"]*)" picture$/ do |post_text, file_name|
image = find_post_by_text(post_text).find(".photo_attachments img[src='#{@image_sources[file_name]}']")
image.should be_present
end
Then /^"([^"]*)" should have (\d+) pictures$/ do |post_text, number_of_pictures|
find_post_by_text(post_text).all(".photo_attachments img").size.should == number_of_pictures.to_i
end

View file

@ -5,13 +5,15 @@ Feature: Creating a new post
And I sign in as "bob@bob.bob"
And I trumpet
Scenario: Posting a public message
And I write "Rectangles are awesome"
Scenario: Posting a public message with a photo
And I write "I love RMS"
When I select "Public" in my aspects dropdown
And I upload a fixture picture with filename "button.gif"
When I press "Share"
When I go to "/stream"
Then I should see "Rectangles are awesome" as the first post in my stream
And "Rectangles are awesome" should be a public post in my stream
Then I should see "I love RMS" as the first post in my stream
And "I love RMS" should be a public post in my stream
Then "I love RMS" should have the "button.gif" picture
Scenario: Posting to Aspects
And I write "This is super skrunkle"
@ -29,9 +31,10 @@ Feature: Creating a new post
And I go to "/stream"
Then I follow "Alice Smith"
Scenario: Uploading a photo
When I write "check out this picture"
Scenario: Uploading multiple photos
When I write "check out these pictures"
And I upload a fixture picture with filename "button.gif"
And I upload a fixture picture with filename "button.gif"
And I press "Share"
And I go to "/stream"
Then "check out this picture" should have my photo
Then "check out these pictures" should have 2 pictures