[rspec-users] very odd controller spec problem

Jim Hughes jeem at hughesorama.com
Wed May 16 02:13:12 EDT 2007


Thank you for the reply.

Doesn't look like it.  The setup does this:

     @fund = mock_model(Fund)
     Fund.should_receive(:find).with(@fund.id.to_s).and_return(@fund)


I changed setup to say

     @fund = mock_model(Fund)
     @fund_id = @fund.id
     Fund.should_receive(:find).with(@fund.id.to_s).and_return(@fund)

And the test to

   it "should provide the fund" do
     @fund_id.should_not be(nil)
     get(:timesheet,{:id=>@fund_id})
     assigns[:fund].should == @fund
   end

Still gives the same error on the "get" line.

Jim


On May 16, 2007, at 12:57 AM, Jeff Dean wrote:

> Is @fund nil?  I'm guessing here, but the []= could be from the  
> underlying attributes (@fund.id is the same as @fund.attributes 
> ['id']).
>
> On 5/16/07, Jim Hughes <jeem at hughesorama.com> wrote:
> Here's a snippet:
>
>    it "should provide the fund" do
>      get(:timesheet,{:id=>@fund.id})
>      assigns[:fund].should == @fund
>    end
>
> Works fine on my box, fails on my CI server.  Here's the output:
>
> NoMethodError in 'The FundController timesheet should provide the  
> fund'
> 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.[]=
> ./spec/controllers/fund_controller_spec.rb:19:
> ./script/spec:4:
>
> The line raising is the "get" line.  I don't see a foo[bar] = x,
> implied anywhere in the statement.
>
> Has anyone seen this?
>
> Thanks for any help.
>
> Jim
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070516/f97224d0/attachment.html 


More information about the rspec-users mailing list