Created
June 2, 2012 04:00
-
-
Save mcspring/2856496 to your computer and use it in GitHub Desktop.
Organize rspec integration testing
This file contains hidden or 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 "Authentication" do | |
subject { page } | |
describe "Signin" do | |
describe "Page" do | |
before :each do | |
visit signin_path | |
end | |
it "should have the title with 'Sign in'" do | |
should have_selector('title', :text => 'Sign in') | |
end | |
it "should have h1 with 'Sign in'" do | |
should have_selector('h1', :text => 'Sign in') | |
end | |
end | |
describe "Form" do | |
before :each do | |
visit signin_path | |
end | |
describe "@valid" do | |
let (:user) { FactoryGirl.create(:user) } | |
before :each do | |
fill_in 'Email', :with => user.email | |
fill_in 'Password', :with => user.password | |
click_button 'Sign in' | |
end | |
it "should have the title with user name" do | |
should have_selector('title', :text => user.name) | |
end | |
it "should have profile link" do | |
should have_link('Profile', :href => user_path(user)) | |
end | |
it "should have sign out link" do | |
should have_link('Sign out', :href => signout_path) | |
end | |
it "should not have sign in link" do | |
should_not have_link('Sign in', :href => signin_path) | |
end | |
end | |
describe "@invalid" do | |
before :each do | |
click_button 'Sign in' | |
end | |
it "should have the title with 'Sign in'" do | |
should have_selector('title', :text => 'Sign in') | |
end | |
it "should have error message with 'Invalid'" do | |
should have_selector('div.alert.alert-error', :text => 'Invalid') | |
end | |
it "should not have error message after visit other link anymore" do | |
click_link 'Home' | |
should_not have_selector('div.alert.alert-error') | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment