-
Notifications
You must be signed in to change notification settings - Fork 553
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
Specs not running with elasticsearch #163
Comments
Is it possible that a separate process is started, with a separate Webmock instance loaded, rather the one configured in the spec helper? Are you able to create a minimum code snippet to reproduce this issue? |
Here are just the bare bones:
Everything else is standard Rails stuff. When running
There's a similar issue on
at the very top of |
That's correct behaviour then. WebMock by default blocks all requests unless you tell him not to do it, by using disable! or allow_net_connect! |
But is the way that I used the 'right' way to do it? Or maybe there are any configuration hooks to put this in? I'm glad that I somehow got it running, but still concerned about whether it's correct. |
Yes, that's a correct way. I.e it's very common to disable_net_connect with exception to localhost when webmock is used with selenium webdriver. If you want to be more specific, and allow only one connection, you could do WebMock.disable_net_connect!(:allow => "localhost:9200") instead. |
Nice, thank you! |
Just for the record:Adding require 'webmock'
WebMock.allow_net_connect! to very top of Workaround:Use a initializers: # File: config/initializers/webmock.rb
if Rails.env.test?
require 'webmock'
WebMock.disable_net_connect!(allow_localhost: true)
end |
thanks @aptx4869 |
Thanks! |
IMHO it is better to add |
@frenkel thanks for suggestion! |
Thank you for your work on the gem. I've been getting sporadic corruption and failures in my rspec test suite. Similar to the discussion in this thread, I have I have a test file1 (for testing fake requests) that I realized that if file2 runs first, then its real requests would fail. I believe this is because rspec loads all the test files and its require statements, which in my case a The suggestion to add the following to the top of spec_helper.rb:
kind of work, but breaks my spork (yes, it's kinda old technology) with cryptic errors. My question: Is there another way? |
I overlooked it, but the suggestion by @aptx4869 to add |
I'm using webmock 1.7.10 and elasticsearch+tire(https://github.com/karmi/tire). When running the specs it tries to access localhost:9200 on start and webmock halts the process because this request is not stubbed. I tried
WebMock.disable!
inspec_helper.rb
right afterrequire 'webmock/rspec'
but this didn't help. Then tried stubbing that URL but it didn't help either.and
also didn't work.
Is there any solution or workaround? This is not specific to some particular specs, this prevents me from being able to run specs at all, so it's a major issue for me, please advice.
The text was updated successfully, but these errors were encountered: