From 27997e95250675056bafce417b1f39fcb05b85f8 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Fri, 16 Mar 2012 22:25:53 +0100 Subject: [PATCH] refactored test method into helpers --- features/step_definitions/posts_steps.rb | 10 +++------- features/support/publishing_cuke_helpers.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index bae24539a..ee7e2854f 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -3,14 +3,11 @@ Then /^the post "([^"]*)" should be marked nsfw$/ do |text| end Then /^the post should be collapsed$/ do - find(".collapsible").should have_css(".expander") - find(".collapsible").has_selector?(".collapsed") + first_post_collapsed? end Then /^the post should be expanded$/ do - find(".expander").should_not be_visible - find(".collapsible").has_no_selector?(".collapsed") - find(".collapsible").has_selector?(".opened") + first_post_expanded? end Then /^I should see an uploaded image within the photo drop zone$/ do @@ -44,8 +41,7 @@ When /^I click on the first block button/ do end When /^I expand the post$/ do - find(".expander").click - wait_until{ !find(".expander").visible? } + expand_first_post end Then /^I should see "([^"]*)" as the first post in my stream$/ do |text| diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb index 9895813a4..8f1762434 100644 --- a/features/support/publishing_cuke_helpers.rb +++ b/features/support/publishing_cuke_helpers.rb @@ -17,6 +17,22 @@ module PublishingCukeHelpers ') end + def expand_first_post + find(".stream_element:first .expander").click + wait_until{ !find(".expander").visible? } + end + + def first_post_collapsed? + find(".stream_element:first .collapsible").should have_css(".expander") + find(".stream_element:first .collapsible").has_selector?(".collapsed") + end + + def first_post_expanded? + find(".stream_element:first .expander").should_not be_visible + find(".stream_element:first .collapsible").has_no_selector?(".collapsed") + find(".stream_element:first .collapsible").has_selector?(".opened") + end + def first_post_text find('.stream_element:first .post-content').text() end