It is likely failing in reality because the relation returned from your AREL select
statement uses method_missing
magic to return a value from the call. This is not the same thing as being defined
. When you mock/stub the "method" on your test object it is likely using the define_method
function which is creating a defined function.
This may do what you want instead.
if respond_to?(:posted_posts)
...
else
...
end