[rspec-users] before_save model callback rspec testing

Yi Wen hayafirst at gmail.com
Mon Jun 23 11:50:19 EDT 2008


Well, at least now we know this is nothing to do with RSpec. My
suggestion is that you comment out the code which will be executed
during a creation, bit by bit in User (such as before_save) and try to
create a user. In this way you can pinpoint where the problem is.


On Mon, Jun 23, 2008 at 10:26 AM, Csongor Bartus <lists at ruby-forum.com> wrote:
> Yi Wen wrote:
>> You don't have attr_accessor :password, :password_confirmation in
>> User, do you? You may want to add this and try again
>
> I had :password, I've added :password_confirmation but still the same:
>
>>> u = User.create!(:login => "test", :email => "test at test.com", :password => "test123", :password_confirmation => "test123")
> NoMethodError: You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.each
>        from
> ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1671:in
> `attributes='
>        from
> ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1505:in
> `initialize_without_callbacks'
>        from
> ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:225:in
> `initialize'
>        from
> ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:726:in
> `new'
>        from
> ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:726:in
> `create!'
>        from (irb):1
>>>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list