Skip to content

Instantly share code, notes, and snippets.

@guange2015
Created May 25, 2012 13:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save guange2015/2788066 to your computer and use it in GitHub Desktop.
authentication_pages_spec.rb
require 'spec_helper'
describe "AuthenticationPages" do
subject {page}
describe "login" do
before {visit login_path}
describe "visit login page" do
it{should have_selector('h1', text:'login')}
end
let(:user) {User.create(name:'ExampleUser', email:'hah@gmail.com',
password: 'foobar', password_confirmation:'foobar')}
describe "with a valid password" do
before do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button 'login'
end
it {should have_selector('h1', text:user.name)}
end
describe "with a invalid password" do
before do
fill_in "Email", with: user.email
fill_in "Password", with: 'invalid'
click_button 'login'
end
it {should have_content('error')}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment