Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert User tests from VCR to Webmock #2

Open
wants to merge 1 commit into
base: contact_lists
Choose a base branch
from

Conversation

NullTerminator
Copy link

Hey @m0dd3r take a look when you get back. I ended up having to have stub_* methods that get called from within a test case. When I stub_request calls in the user_mocks.rb file they would only stub for the first test then got cleared out.

There is logic in place so the stub_* methods are noop if the LIVE_API_CALLS environment var is set to "true". It's sort of weird still having them called from tests when they won't stub, but it works.

@m0dd3r
Copy link

m0dd3r commented Jun 12, 2015

bah, well that sucks. Looks like there's an open issue on webmock's github page regarding global stubs, but no activity. I really don't like the idea of calling stub_* methods when they're defined as noops. It's misleading at best. Got any other ideas?

@NullTerminator
Copy link
Author

The other way I can think to make this work is to define a global/generic "before each" that just does all the stubs if needed or is a noop if doing live calls. But it seems Minitest doesn't support this. It has setup that you can add to each Test class, but no way to define something at the suite level which will then run before each. It has before_setup, but the docs say that's for plugins and shouldn't be used for tests.

test_helper could define a global_setup or suite_setup method which, if not doing live api calls, stubs all the calls. Test classes could then call global_setup from their setup method. This way tests wouldn't be calling stub_* which ends up not stubbing anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants