Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@billbillington billbillington commented Mar 13, 2014

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

This comment has been minimized.

Copy link

@billbillington billbillington commented Mar 13, 2014

Why not load all the page objects globally?

@billbillington

This comment has been minimized.

Copy link

@billbillington billbillington commented Mar 14, 2014

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