Using Ruby 1.8.6, stubbing a finder method to return an Array does not work when the code under test calls the 'count' method on the result:
User.any_instance.stubs(:friends).returns([user1, user2])
That's because Array.count has only been added in Ruby 1.8.7. Rails also adds a count method dynamically, I believe through the ActiveRecord::Calculations module.
Is there any way to turn this result array into something that behaves exactly as the special Array kind returned by a Rails finder method? When paginating results, it's easy: I can simply call [].paginate. But that doesn't work with normal finder results. I tried [].extend(ActiveRecord::Calculations)
but that doesn't work either.