On Tue, Nov 13, 2012 at 12:46 PM, Javix <[email protected]> wrote:
> The result array contains ActiveRecord::Relation objects as explained in
> Rails API:
>
> named scopes act like an Array, implementing Enumerable;
> Shirt.red.each(&block), Shirt.red.first, and Shirt.red.inject(memo, &block)
> all behave as if Shirt.red really was an Array.
>
> So is there a way to either test them or transform into AR objects to test?

Sure. They automatically convert to or act as arrays in many cases, or
you can explicitly convert them using to_a (or all). Try it and see!

Also, a scope is part of a model, so you should probably be writing a
unit test (account_spec.rb), not a controller test.

Good luck!

see also http://guides.rubyonrails.org/active_record_querying.html#scopes

--
Alex Chaffee - [email protected]
http://alexchaffee.com
http://twitter.com/alexch

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to