Guest User

Untitled

a guest
May 17th, 2018
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. require File.dirname(__FILE__) + '/../spec_helper'
  2.  
  3. describe "A User" do
  4.  
  5. before(:each) do
  6. @user = User.new :login => 'quentin', :password => 'blah', :password_confirmation => 'blah', :email => 'quentin@example.com'
  7. end
  8.  
  9. it "should have valid associations" do
  10. @user.save!
  11. @user.should have_valid_associations
  12. end
  13. ## the following spec raises an error
  14. it "should protect against updates to secure attributes" do
  15. @user.save
  16. lambda{
  17. @user.update_attributes(:created_at => 3)
  18. }.should raise_error(ActiveRecord::ProtectedAttributeAssignmentError)
  19. end
  20.  
  21. end
  22.  
  23. ## rake rspec shows
  24. should protect against updates to secure attributes
  25. uninitialized constant ActiveRecord::ProtectedAttributeAssignmentError
  26. /Users/carltanner/Sites/rails/caboo.se-sample-app-v3/spec/models/user_spec.rb:18
  27. 16 lambda{
  28. 17 @user.update_attributes(:created_at => 3)
  29. 18 }.should raise_error(ActiveRecord::ProtectedAttributeAssignmentError)
  30. 19 end
  31. 20
Add Comment
Please, Sign In to add comment