Created
February 14, 2013 03:06
-
-
Save Fire-Dragon-DoL/4950295 to your computer and use it in GitHub Desktop.
How to test sign_in method?
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 'spec_helper' | |
describe 'Users' do | |
describe 'Login' do | |
it 'should login the user and show logout link' do | |
user = FactoryGirl.create(:user) | |
visit new_user_session_path | |
fill_in 'Email', with: user.email | |
fill_in 'Password', with: user.password | |
click_button 'Sign in' | |
page.should have_content('Logout') | |
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
module ValidUserRequestHelper | |
def sign_in_as_a_valid_user(role = nil) | |
role = 'user' if role.nil? | |
@user ||= FactoryGirl.create(:user, role: role) | |
visit new_user_session_path | |
fill_in 'Email', with: @user.email | |
fill_in 'Password', with: @user.password | |
click_button 'Sign in' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment