[rspec-users] authentication, controller specs. I think I'm missing something simple ....
s.ross
cwdinfo at gmail.com
Sun Jun 10 18:08:27 EDT 2007
Try pulling do_get outside the block and see if that helps...
Just a thought.
On Jun 10, 2007, at 12:18 PM, Joe Van Dyk wrote:
> On 6/9/07, Rick Tessner <ricktessner at canada.com> wrote:
>> On Sat, 2007-09-06 at 14:34 -0700, Joe Van Dyk wrote:
>>> Your pasties have wrapped lines in them for some reason, which makes
>>> matching up the errors to the lines of code difficult.
>>
>> Dang. Sorry about that. Looks like it was the
>> things_controller_spec
>> was messed up for some reason. Re-pastied that.
>>
>> The three pasties are then:
>>
>> things_controller http://pastie.caboo.se/69136
>> things_controller_spec http://pastie.caboo.se/69166
>> Errors w/ find(:all) http://pastie.caboo.se/69138
>
> I don't have the solution and I've ran into this in the past. But at
> least I can explain what is happening. :-)
>
> @thing = mock_model(Thing)
> Thing.stub!(:find).and_return([@thing])
>
> @current_user = mock_model(User, :things => [@thing])
> controller.should_receive(:login_required).with
> (no_args).once.and_return(true)
> controller.should_receive(:current_user).with
> (no_args).and_return(@current_user)
>
> So, when you do:
> current_user.things.find
>
> You are calling the find method on an array that contains one @thing
> object. The find you are calling is Enumerable#find (the plain old
> Ruby version, not the ActiveRecord::Base::find version).
> Enumerable#find expects a block.
>
> i.e.
> ["hello, "world"].find { |e| e.include?('el') }
> would return "hello"
>
> However, in the Rails code, when you call current_user.things.find,
> You are calling Thing::find with a scoped find for only the Things
> that belong to the current user. That's an entirely different find
> method.
>
> Hope that makes sense. I don't know what the solution is.
>
> Joe Van Dyk
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
Steve Ross
sross at calicowebdev.com
http://www.calicowebdev.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070610/e27cbc70/attachment-0001.html
More information about the rspec-users
mailing list