Last active
August 29, 2015 13:57
-
-
Save mattheworiordan/9527117 to your computer and use it in GitHub Desktop.
Proposed DLS and structure for our tests using Page objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Why not load all the page objects globally?
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
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