From 4382d45e821814ce953b911812bd7012c4a8d74a Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Mon, 6 Feb 2012 12:25:02 -0800 Subject: [PATCH] almost failing cuke --- features/posts_from_main_page.feature | 5 ++++ features/step_definitions/factory_steps.rb | 4 +++ features/step_definitions/message_steps.rb | 18 +++++++++++++ features/step_definitions/posts_steps.rb | 12 +++++++++ features/support/publishing_cuke_helpers.rb | 29 +++++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 features/step_definitions/message_steps.rb create mode 100644 features/support/publishing_cuke_helpers.rb diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index fffe3073c..9b45e5aaf 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -24,6 +24,11 @@ Feature: posting from the main page And I go to the aspects page Then I should see "I am eating a yogurt" within ".stream_element" + Scenario: posting a message appends it to the top of the stream + Given I have a prexisting post + And I post "hey there" + Then I should see "hello there" as the first post in my stream + Scenario: post a text-only message to just one aspect When I select only "PostingTo" aspect And I expand the publisher diff --git a/features/step_definitions/factory_steps.rb b/features/step_definitions/factory_steps.rb index 15e406e78..91032b057 100644 --- a/features/step_definitions/factory_steps.rb +++ b/features/step_definitions/factory_steps.rb @@ -32,6 +32,10 @@ end World(FactoryMethods) +Given /I have a prexisting post/ do + Factory(:status_message, :author => @me.person, :public => true) +end + Given %r{^I have a (.+)$} do |model_name| create_from_table(model_name, {}, 'user' => @me) end diff --git a/features/step_definitions/message_steps.rb b/features/step_definitions/message_steps.rb new file mode 100644 index 000000000..ded072ac1 --- /dev/null +++ b/features/step_definitions/message_steps.rb @@ -0,0 +1,18 @@ +Then /^I should see the "(.*)" message$/ do |message| + text = case message + when "alice is excited" + @alice ||= Factory(:user, :username => "Alice") + I18n.translate('invitation_codes.excited', :name => @alice.name) + when "welcome to diaspora" + I18n.translate('users.getting_started.well_hello_there') + when 'you are safe for work' + I18n.translate('profiles.edit.you_are_safe_for_work') + when 'you are nsfw' + I18n.translate('profiles.edit.you_are_nsfw') + when 'hello' + "well hello there man" + else + raise "muriel, you don't have that message key, add one here" + end + page.should have_content(text) +end \ No newline at end of file diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index 2401c89d5..e454eb5e4 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -34,3 +34,15 @@ end When /^I click on the first block button/ do find(".block_user").click end + + + +Then /^"I should see "([^"]*)" as the first post in my stream$/ do |text| + first_post_text.should include(text) +end + +Given /^"I post "([^"]*)"$/ do |text| + make_post(text) +end + + diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb new file mode 100644 index 000000000..4bcb3b61e --- /dev/null +++ b/features/support/publishing_cuke_helpers.rb @@ -0,0 +1,29 @@ +module PublishingCukeHelpers + def make_post(text) + click_publisher + fill_in 'status_message_fake_text', :with => text + click_button :submit + end + + def click_publisher + page.execute_script(' + $("#publisher").removeClass("closed"); + $("#publisher").find("textarea").focus(); + ') + end + + def first_post_text + find('.stream_element:first .post-content').text() + end + + def find_post_by_text(text) + find(".stream_element:contains('#{text}')") + end + + def assert_nsfw(text) + post = find_post_by_text(text) + post.find(".shield").should be_present + end +end + +World(PublishingCukeHelpers) \ No newline at end of file