Skip to content

Commit

Permalink
Lots of step refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Waite committed Nov 5, 2011
1 parent 1218728 commit 30719e3
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 29 deletions.
8 changes: 4 additions & 4 deletions features/step_definitions/common_steps.rb
@@ -1,15 +1,15 @@
Then /^I should see the error "([^"]*)"$/ do |message|
should have_css('.error_messages li', message)
current_page.errors.should include(message)
end

Then /^I should see the alert "([^"]*)"$/ do |message|
find('#flash_alert').text.should == message
current_page.alert.should == message
end

Then /^I should see the notice "([^"]*)"$/ do |message|
find('#flash_notice').text.should == message
current_page.notice.should == message
end

Then /^I should see a message "([^"]*)"$/ do |message|
should have_content(message)
current_page.should have_message(message)
end
8 changes: 4 additions & 4 deletions features/step_definitions/featured_steps.rb
Expand Up @@ -8,17 +8,17 @@
end

Then /^I should see a message that I have voted on all the submissions$/ do
series_page.has_all_voted_on_message?.should == true
series_page.should have_all_voted_on_message
end

Then /^I should not see a message that I have voted on all the submissions$/ do
series_page.has_all_voted_on_message?.should == false
series_page.should_not have_all_voted_on_message
end

Then /^I should not see a featured submission$/ do
series_page.has_featured_submission?.should == false
series_page.should_not have_featured_submission
end

Then /^I should see a featured submission$/ do
series_page.has_featured_submission?.should == true
series_page.should have_featured_submission
end
4 changes: 2 additions & 2 deletions features/step_definitions/page_steps.rb
@@ -1,7 +1,7 @@
Then /^the page title should be "([^"]*)"$/ do |title|
series_page.page_title.should == title
current_page.page_title.should == title
end

Then /^the window title should be "([^"]*)"$/ do |title|
series_page.window_title.should == title
current_page.window_title.should == title
end
11 changes: 4 additions & 7 deletions features/step_definitions/series_steps.rb
Expand Up @@ -57,7 +57,7 @@ def create_series
end

Then /^I should see the series "([^"]*)"$/ do |name|
series_index_page.series_names.include?(name).should == true
series_index_page.series_names.should_includename
end

Then /^(\d+) series should exist$/ do |count|
Expand All @@ -79,10 +79,7 @@ def create_series
end

When /^I create a new series "([^"]*)"$/ do |name|
visit new_series_path
fill_in :name, :with => name
click_button 'Create Series'
should have_content('Successfully created series')
new_series_page.create name
end

Then /^the stats for that series should be:$/ do |table|
Expand All @@ -101,10 +98,10 @@ def create_series
end

When /^I try to create a new series$/ do
click_link 'New Series'
new_series_page.visit
end

When /^I try to create a series without a name$/ do
visit new_series_path
new_series_page.visit
click_button 'Create Series'
end
5 changes: 2 additions & 3 deletions features/step_definitions/submission_steps.rb
Expand Up @@ -82,7 +82,7 @@ def create_submissions_and_series(hashes)

When /^I try to create a submission without a name$/ do
series = Factory(:series)
visit series_path(series)
series_page.visit series
click_link 'New Submission'
click_button 'Create Submission'
end
Expand All @@ -95,8 +95,7 @@ def create_submissions_and_series(hashes)

When /^I post a submission "([^"]*)"$/ do |name|
click_link 'New Submission'
fill_in :name, :with => name
click_button 'Create Submission'
new_submission_page.create(name)
end

Then /^I should see only the submission "([^"]*)"$/ do |expected|
Expand Down
26 changes: 24 additions & 2 deletions features/support/page/base.rb
Expand Up @@ -4,11 +4,33 @@ class Base
include Rails.application.routes.url_helpers

def page_title
session.find('h1').text
find('h1').text
end

def window_title
session.find('title').text
find('title').text
end

def alert
find('#flash_alert').text
end

def notice
find('#flash_notice').text
end

def has_message?(message)
has_content?(message)
end

def errors
all('.error_messages li').collect(&:text)
end

def method_missing(*args)
if session.respond_to?(args.first)
session.send(*args)
end
end

private
Expand Down
8 changes: 6 additions & 2 deletions features/support/page/login_page.rb
Expand Up @@ -3,9 +3,13 @@ module Page
class LoginPage < Page::Base

SIGNED_IN_MESSAGE = "Signed in successfully."


def path
new_user_session_path
end

def visit
session.visit new_user_session_path
session.visit path
end

def sign_in(email, password)
Expand Down
6 changes: 5 additions & 1 deletion features/support/page/logout_page.rb
Expand Up @@ -2,8 +2,12 @@ module Page

class LogoutPage < Page::Base

def path
destroy_user_session_path
end

def visit
session.visit destroy_user_session_path
session.visit path
end

end
Expand Down
9 changes: 8 additions & 1 deletion features/support/page/series/new_series_page.rb
Expand Up @@ -3,7 +3,14 @@ module Series
class New < Page::Base

def visit
session.visit new_series_path
Capybara.current_session.visit new_series_path
end

def create(name)
visit
fill_in :name, :with => name
click_button 'Create Series'
should have_content('Successfully created series')
end

end
Expand Down
6 changes: 5 additions & 1 deletion features/support/page/series/series_index_page.rb
Expand Up @@ -2,8 +2,12 @@ module Page
module Series
class Index < Page::Base

def path
series_index_path
end

def visit
session.visit series_index_path
session.visit path
end

def series_count
Expand Down
8 changes: 6 additions & 2 deletions features/support/page/series/series_page.rb
Expand Up @@ -2,8 +2,12 @@ module Page
module Series
class Show < Page::Base

def path(series)
series_path(series)
end

def visit(series)
session.visit series_path(series)
session.visit path(series)
end

def has_featured_submission?
Expand All @@ -19,7 +23,7 @@ def has_all_voted_on_message?
end

def click_button_for_submission(button_label, submission_name)
submission = Submission.find_by_name(submission_name)
submission = ::Submission.find_by_name(submission_name)
session.within(submission_sel(submission)) do
session.click_button button_label
end
Expand Down

0 comments on commit 30719e3

Please sign in to comment.