Module Foo
def querying_result(criteria)
User.find_by_account(current_account).where(criteria: criteria)
end
end
I write a unit test for the above module and want to stub current_account
variable which is coming from application controller.
I tried with following
Foo.stubs(current_account: @user.account).returns(@user.account)
Foo.any_instance.stub(current_account:@user.account).and_return(@user.account)
My Test file
class FooTest << ActiveSupport::TestCase
context "querying the result"
setup do
@user = User.first
end
should "return all users" do
users = querying_result(criteria)
assert_equal users.count, 1
end
end
what am I missing here. Kindly help
Aucun commentaire:
Enregistrer un commentaire