[rspec-users] Testing shorthand array push <<

David Chelimsky dchelimsky at gmail.com
Sat Jul 21 09:24:48 EDT 2007


On 7/20/07, Lance Carlson <lancecarlson at gmail.com> wrote:
> Hi everyone,
>
> I'm trying to test the shorthand way to push objects into an array. My
> controller looks like:
>
> current_user.foos << @foo
>
> and I keep getting an error like Mock 'foos' received unexpected message :<<
> with <FooClass>
>
> does anyone have a good solution for this?
>
> I tried controller.send(:current_user).labels.stub!(:<<).and_return([]) and
> that didn't work.

That should work. Would you please post the rspec example and the
controller code?

>
> TIA!
> -Lance
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list