From e823fc02793a03b77a6b2aefd032b9f969a17224 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Sat, 10 May 2014 17:54:56 +0200 Subject: [PATCH] Implements login macros --- spec/spec_helper.rb | 3 +++ spec/support/login_macros.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 spec/support/login_macros.rb 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