diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 06839d80..257c19d8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,6 +47,9 @@ RSpec.configure do |config| # Use capybara-webkit as default javascript driver Capybara.javascript_driver = :webkit + # Includes support/login_macros for feature tests + config.include LoginMacros, type: :feature + # As we start from scratch in April 2014, let's forbid the old :should syntax config.expect_with :rspec do |c| c.syntax = :expect diff --git a/spec/support/login_macros.rb b/spec/support/login_macros.rb new file mode 100644 index 00000000..3694a12b --- /dev/null +++ b/spec/support/login_macros.rb @@ -0,0 +1,12 @@ +module LoginMacros + + def sign_in(user) + visit new_user_session_path + + fill_in 'user_email', with: user.email + fill_in 'user_password', with: user.password + find(:xpath, "//div[@id='content']//input[@name='commit']").click + + expect(page.has_content?('Signed in successfully')).to be true + end +end