I would like to stub a web service proxy before all my unit tests. I could call some shared code in each unit test, but I was wondering if there is a better way.
I am using Shoulda.
Thanks
in test/test_helper you can do the following:
class ActiveSupport::TestCase
def stub_some_stuff
…
end
setup :stub_some_stuff
end
Be careful to ensure you don't just do it once by putting it outside of a setup block, doing so may result in the stub being torn down by the first test, and then all future requests just go straight through!
test / test_helper是通用代码的好地方-这将注入到您的TestCases中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.