[rspec-users] Problem with view spec - works inside the browser but spec fails with nil object

Hans de Graaff hans at degraaff.org
Sun Nov 11 03:01:27 EST 2007

You are trying to test a lot of things at the same time, which is one of
the reasons that it is now hard to diagnose a problem.

I would tackle this by 
a) writing a separate spec for the partial _question_for_candidate
b) write a separate spec for the helper that renders the question
b) in the view spec for /survey/show use should_receive to determine
that the helper is actually being called
c) not use any fixtures in the view specs but instead use mocks for
that: it's faster and you can check exactly what needs to happen instead
of relying on what happens to be in the fixture.

I'm afraid that I don't see immediately why your current setup won't
work, but untangling things along the lines sketched above should
hopefully get you to a situation where it becomes easier to see what

>   before(:each) do
>     assigns[:configurations] = {:survey_name => 'Whatever'} 
>     assigns[:questions] = Array.new
>     assigns[:questions][4] = questions(:faixa_etaria)

I am a little bit suspicious about this construction, though. I'm not
sure whether assigns is a normal Array in this case, so I'd create the
Array and populate it before handing it to assigns:

@questions = Array.new
@questions[4] = ...
assigns[:questions] = @questions

Kind regards,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071111/a479f059/attachment.bin 

More information about the rspec-users mailing list