diff --git a/features/step_definitions/trumpeter_steps.rb b/features/step_definitions/trumpeter_steps.rb index 378d30aeb22b31a9960973a1d1872576ff720843..999ef806bc029a288715007ee2f51e5a707e8ada 100644 --- a/features/step_definitions/trumpeter_steps.rb +++ b/features/step_definitions/trumpeter_steps.rb @@ -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 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 my photo$/ do |status_text| - find_post_by_text(status_text).find(".photo_attachments img")["src"].should == @image_source +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 \ No newline at end of file diff --git a/features/trumpeter.feature b/features/trumpeter.feature index eac163fc598779dad5e6f25bf5854fd890d1ba1e..f33cc68186bb8eb6d406b56dc9b6470a8e553b27 100644 --- a/features/trumpeter.feature +++ b/features/trumpeter.feature @@ -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