Skip to content

Instantly share code, notes, and snippets.

@mattheworiordan
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattheworiordan/9527117 to your computer and use it in GitHub Desktop.
Save mattheworiordan/9527117 to your computer and use it in GitHub Desktop.
Proposed DLS and structure for our tests using Page objects
require 'integration/spec_helper'
feature 'New user sign up', :js => true do
pages :home_page, :registration_page, :registration_complete_page
let(:user_email) { 'matt@econsultancy.com' }
scenario %{
User arrives on the home page, follows the sign up promotion,
fills in the form incorrectly, then corrects their mistakes,
completes submission, and receives a welcome email after sign up
} do
visit_signup_from_home_promotion
fill_in_form_incorrectly
complete_registration
ensure_email_received
end
def visit_signup_from_home_promotion
visit home_page
home_page.register_promotion_link.click
end
def fill_in_form_incorrectly
expect(current_page).to be_registration_page
registration_page.form.submit
expect(registration_page).validation_errors.to include(name: 'is required')
expect(registration_page).validation_errors.to include(email: 'is required')
end
def complete_registration
registration_page.form.fill_in(name: 'Matthew', email: user_email)
registration_page.form.submit
expect(current_page).to be_registration_complete_page
end
def ensure_email_received
expect(user(user_email)).to have_received_welcome_email
end
end
@billbillington
Copy link

I like how the code looks but I think the dsl might be overkill. I'm adding a new commit to the pr encorporating some of the feedback here and using this as the basis

@billbillington
Copy link

Why not load all the page objects globally?

@billbillington
Copy link

ignore the above I tried without and now think the dsl is good and using form objects separate from the page object itself is also a great idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment