Guest User

Untitled

a guest
May 7th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
  2.  
  3. describe AuthenticationSystem do
  4.  
  5. before :each do
  6. @auth = Class.new do; include AuthenticationSystem; end.new
  7. @user = User.create!(:email => 'user@example.com', :password => 'secret')
  8. end
  9.  
  10. describe "the user property" do
  11. it "should initially be nil" do
  12. @auth.user.should be_nil
  13. end
  14.  
  15. it "should be the authenticated user after authentication" do
  16. @auth.authenticate('user@example.com', 'secret')
  17. @auth.user.id.should == @user.id
  18. end
  19.  
  20. it "should be nil after a failed authentication" do
  21. @auth.authenticate('user@example.com', 'guess')
  22. @auth.user.should be_nil
  23. end
  24. end
  25. end
Add Comment
Please, Sign In to add comment