Created
July 7, 2010 04:00
-
-
Save paulelliott/466280 to your computer and use it in GitHub Desktop.
Example rspec integration spec for a guest signing in.
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' | |
context 'as a guest on the sign in page' do | |
#Make sure your factory generates a valid user for your authentication system | |
let(:user) { Factory(:user) } | |
#Browse to the homepage and click the Sign In link | |
before do | |
visit root_path | |
click 'Sign In' | |
end | |
context 'with valid credentials' do | |
#Fill in the form with the user’s credentials and submit it. | |
before do | |
fill_in 'Email', :with => user.email | |
fill_in 'Password', :with => 'password' | |
click 'Submit' | |
end | |
it 'has a sign out link' do | |
page.should have_xpath('//a', :text => 'Sign Out') | |
end | |
it 'knows who I am' do | |
page.should have_content("Welcome, #{user.email}!") | |
end | |
end | |
context 'with invalid credentials' do | |
#No form entry should produce an error | |
before do | |
click 'Submit' | |
end | |
it 'has errors' do | |
page.should have_xpath("//div[@id='errorExplanation']") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment