Skip to content

Instantly share code, notes, and snippets.

@anaerobeth
Forked from HeroicEric/authentication_helper.rb
Created October 3, 2013 02:37
Show Gist options
  • Save anaerobeth/6803884 to your computer and use it in GitHub Desktop.
Save anaerobeth/6803884 to your computer and use it in GitHub Desktop.
# spec/support/authentication_helper.rb
module AuthenticationHelper
def sign_in_as(user)
visit new_user_session_path
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Sign in"
expect(page).to have_link('Sign out')
end
end
require 'spec_helper'
feature "user edits their profile" do
scenario "some awesome description" do
user = FactoryGirl.create(:user)
sign_in_as user
# do stuff as a logged in user
end
end
# spec/spec_helper.rb
# ... omitted
RSpec.configure do |config|
# ... omitted
config.include AuthenticationHelper
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment