User.find_by(email: @user.email) is valid depending which version of Rails
you are on; I believe Rails 4.x supports this format. My guess is that your
user isn't valid and thus does not save. Change line 87 to use save!:
before { @user.save! }
On Tue, Jul 22, 2014 at 4:15 AM, Javix <[email protected]> wrote:
>
>
> On Tuesday, July 22, 2014 8:23:07 AM UTC+2, Roelof Wobben wrote:
>>
>> Hello,
>>
>> I do still follow the Hartl tutorial.
>> Am at chapter 6 and according to the manual the test schould be
>> successfull but I see these error messages:
>>
>> Failures:
>>
>>
>>
>>
>>
>>
>>
>> 1) User when password doesn't match confirmation return
>> value of authenticate method with valid password
>>
>>
>> Failure/Error: it { should eq found_user.
>> authenticate(@user.password) }
>>
>>
>>
>> NoMethodError:
>>
>>
>>
>> undefined method `authenticate' for nil:NilClass
>>
>>
>>
>> # ./spec/models/user_spec.rb:91:in `block (5
>> levels) in <top (required)>'
>>
>> You can find my code here : https://github.com/roelof1967/
>> sample_app_nutrious/tree/chapter_six
>>
>> Roelof
>>
>
> The error comes from the lien 91.
>
> let(:found_user) { User.find_by(email: @user.email) }
>
> Try to replace it as follows:
>
> let(:found_user) { User.find_by_email(@user.email)
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/d945fb01-2370-4b03-9460-3b3801ecad74%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/d945fb01-2370-4b03-9460-3b3801ecad74%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/CAKCESdjob5pMujWBqgaDDmgXGk89h9v_ij4FgUpTedFJVG-SSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.