When I change it to :
describe "when password doesn't match confirmation" do
before { @user.password_confirmation = "mismatch" }
it { should_not be_valid }
describe "with a password that's too short" do
before { @user.password = @user.password_confirmation = "a" * 5 }
it { should be_invalid }
end
I still see the old error
Also when I change the indention so it matches the second it.
Roelof
Op woensdag 23 juli 2014 17:28:23 UTC+2 schreef Aaron Kromer:
>
> You’ll need to provide more details. Fixing that end worked for me.
>
>
> On Wed, Jul 23, 2014 at 8:08 AM, Roelof Wobben <[email protected]
> <javascript:>> wrote:
>
>> hello,
>>
>> I did add a end on rule 80 but still the test fail. Im now on holidays
>> for 2 weeks and will look at this topic after my holidays,
>>
>> Op dinsdag 22 juli 2014 22:57:45 UTC+2 schreef Javix:
>>>
>>>
>>> On 22 Jul 2014, at 19:05, Aaron Kromer <[email protected]> wrote:
>>>
>>> This is one reason I personally dislike this style of specs combined
>>> with AR hooks. It makes more difficult than necessary to troubleshoot.
>>>
>>> As @javix pointed out, line 20
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L20>
>>>
>>> has:
>>>
>>> it { should be_valid }
>>>
>>> At this point the subject is what is defined on line 11
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L11>
>>> :
>>>
>>> subject { @user }
>>>
>>> The ivar @user is defined in the before block on line 5
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L5-L9>
>>> :
>>>
>>> before do
>>> @user = User.new(name: "Example User", email: "[email protected]",
>>> password: "foobar", password_confirmation: "foobar")
>>> end
>>>
>>> However, when the spec on line 91
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L91>
>>>
>>> runs it calls save in the before block on line 87
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L87>
>>> :
>>>
>>> before { @user.save }
>>>
>>> By using save! it raises an error and confirms that the model was
>>> invalid. Here’s the error:
>>>
>>> Failure/Error: before { @user.save! }
>>> ActiveRecord::RecordInvalid:
>>> Validation failed: Password confirmation doesn't match Password
>>>
>>> Dumping the attributes of @user shows there is a mismatch in the
>>> password:
>>>
>>> {
>>> password: "foobar",
>>> password_confirmation: "mismatch",
>>> }
>>>
>>> This is happening because there is an additional before hook that runs
>>> defined on line 87
>>> <https://github.com/roelof1967/sample_app_nutrious/blob/90dcb47/spec/models/user_spec.rb#L78>.
>>>
>>> On a visual inspection, it doesn’t appear that it is initially related
>>> because the indenting is out of sync. The end on line 84 really applies
>>> to the describe on line 81.
>>>
>>>
>>> On Tue, Jul 22, 2014 at 10:13 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 va
>>>>> lue 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
>>>>>
>>>>
>>>> @Aaron: as of his gemfile he uses 4.1.4. I don't think save! could
>>>> solve that because the previous example pass (line 20):
>>>>
>>>> it { should be_valid }
>>>>
>>>> The problem is that he is callilng authenticate on Nil.
>>>>
>>>>
>>>> --
>>>> 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/09a1007d-9811-4548-80f9-e5b0f3f33a17%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/rspec/09a1007d-9811-4548-80f9-e5b0f3f33a17%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>> @Aaron: Well done ! I haven’t pick up the indention of do-end block.
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "rspec" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/rspec/3j266FPKVy4/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/CAKCESdi5aX6_4_8Fguvd0WNA3K%3DrCZy622EoiTHz9G6kK%2BAG%2BA%
>>> 40mail.gmail.com
>>> <https://groups.google.com/d/msgid/rspec/CAKCESdi5aX6_4_8Fguvd0WNA3K%3DrCZy622EoiTHz9G6kK%2BAG%2BA%40mail.gmail.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] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rspec/513a7aec-cca3-4f22-9ec7-d4889b4d0b59%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/rspec/513a7aec-cca3-4f22-9ec7-d4889b4d0b59%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/8da7033b-95a4-4e61-88a8-bb2ea4a94748%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.