Reputation: 1775
Can I define all of my stub methods at one place instead of defining them in each test case? For example i have this piece of code
SocialNetworks::Facebook.any_instance.stubs(:update_status).returns(true)
in multiple test cases. But if I move it in test_helper.rb file then running test cases won't work. Does mocha gem allowed to place these stubs at one place?
I am using rails Minitest for testing rails app. And mocha gem for stubing and mocking.
Upvotes: 0
Views: 623
Reputation: 1010
You can do that in setup
callback, like:
class YourTest < ActiveSupport::TestCase
setup do
SocialNetworks::Facebook.any_instance.stubs(:update_status).returns(true)
end
end
setup
is called before each test case.
Upvotes: 2