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/2788062 to your computer and use it in GitHub Desktop.
user_spec.rb
require 'spec_helper'
describe User do
subject {@user}
before {@user = User.new(name:'ExampleUser', email:'hah@gmail.com',
password: 'foobar', password_confirmation:'foobar') }
it {should be_valid}
it {should respond_to(:name)}
it {should respond_to(:email)}
it {should respond_to(:password)}
it {should respond_to(:password_confirmation)}
describe "Login" do
it "should authenticate success when use valid password" do
@user.authenticate('foobar').should be_true
end
it "should authenticate fail when use invalid password" do
@user.authenticate('invalid').should be_false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment