[rspec-users] Testing variables in controllers?

Ramon Tayag ramon.tayag at gmail.com
Thu Nov 6 12:30:11 EST 2008


Cool thanks Fernando, Matt, Nick - it seems like I haven't made my
models fat enough.  That seems to be the answer :)

Ramon Tayag



On Fri, Nov 7, 2008 at 12:50 AM, Nick Hoffman <nick at deadorange.com> wrote:
> On 2008-11-06, at 09:36, Ramon Tayag wrote:
>>
>> How do you test that your controller fetched the right records?
>>
>> I have an action that returns a different set of records based on
>> whether or not the current_user is the "owner" of the profile being
>> viewed.
>>
>> Code is here http://pastie.org/308685.
>>
>> "controller.submissions.size.should == 1" makes sense but it doesn't
>> work.  Of course, I might be doing this wrong altogether!  Very new to
>> rspec.
>>
>> Thanks!
>> Ramon Tayag
>
> Hi Ramon. I'd refactor most of what's in the "before :show do" block into a
> couple of User instance methods (or whichever model @user belongs to). For
> example: http://pastie.org/308814
>
> Cheers,
> Nick
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list