Hello
I am still learning to specify named_scopes, having some troubles and
needing some help.
This is the situation.
I have already spec two or three named_scopes independently.
but now, I want to spec a function that combines somes of these
named_scopes dynamically.
Something like this
class Thing
named_scope foo, .....
named_scope bar, ....
named_scope baz, ....
def complex_query(condition1, condition2, condition3)
scope = Thing.scoped({})
scope = scope.scoped( Thing.foo.proxy_options ) if condition1
scope = scope.scoped( Thing.bar.proxy_options ) if condition2
scope = scope.scoped( Thing.baz.proxy_options ) if condition3
scope
end
end
I don't know if there is a better way to implement it, but it works.
The problem is with the specification. I don't know how to do it with
mocking.
I have already spec and test the named_scopes against the database and
think
that this time I have to test only the chaining and not the result.
Juanma Cervera
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users