ruby on rails 3 - Following rspec exception handling, getting 'NoMethodError' for 'expect' -


confused why rspec method isn't working. looking @ answer here: how use rspec's should_raise kind of exception? , have tried combinations proposed reason, i'm still getting nomethoderror.

here exception

exception encountered: #<nomethoderror: undefined method `expect' #<class:0x007fa5bd8e4120>> 

here method:

describe "admin should not accesible" expect { user.new(name: "example name", email: "email@example.org", password: "foobar", password_confirmation: "foobar", admin: "true") }.should raise_error(activemodel::massassignmentsecurity::error) end 

i got error earlier know method doing want do:

1) user admin should not accesible failure/error: hey = user.new(name: "hello", email: "hey@hey.org", password: "foobar", password_confirmation: "foobar", admin: "true") activemodel::massassignmentsecurity::error: can't mass-assign protected attributes: admin 

i running:

rspec 2.1.0 on rails 3 guard-spork 0.3.2 , spork 0.9.0

this classic! missing it block!

describe "admin should not accesible" "should bla" expect { user.new(name: "example name", email: "email@example.org", password: "foobar", password_confirmation: "foobar", admin: "true") }.should raise_error(activemodel::massassignmentsecurity::error) end end 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -