-
-
Save joshuaclayton/cd39b0a38d077ff36883 to your computer and use it in GitHub Desktop.
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
# spec/support/integration.rb | |
RSpec.configure do |config| | |
config.include Integration::SignInHelpers, only: :integration | |
config.include Integration::NoticeHelpers, only: :integration | |
end |
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
# spec/support/integration/notice_helpers.rb | |
module Integration | |
module NoticeHelpers | |
def user_sees_notice(text) | |
expect(page).to have_css '.flash.notice', text: text | |
end | |
end | |
end |
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
# spec/support/integration/sign_in_helpers.rb | |
module Integration | |
module SignInHelpers | |
def sign_in_with(email, password) | |
visit sign_in_path | |
fill_in 'Email', with: email | |
fill_in 'Password', with: password | |
click_button 'Sign In' | |
end | |
end | |
end |
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
# spec/integration/sign_in_spec.rb | |
feature 'Signing in' do | |
background do | |
create :user, email: 'person@example.com', password: 'password' | |
end | |
scenario 'signs the user in successfully with a valid email and password' do | |
sign_in_with 'person@example.com', 'password' | |
user_sees_welcome_message 'Welcome, person@example.com' | |
end | |
scenario 'notifies the user if his email or password is invalid' do | |
sign_in_with user.email, 'wrong password' | |
user_sees_notice 'Invalid email or password' | |
end | |
def user_sees_welcome_message(text) | |
expect(page).to have_css 'nav .greeting', text: text | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are drivers other than Capybara compatible with RSpec?