Created
March 24, 2017 14:58
-
-
Save roalcantara/16650889e29dfb920fc5f0cc833bd5dd to your computer and use it in GitHub Desktop.
Rails > Disabling elasticsearch requests durying rspec tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/elasticsearch.rb | |
RSpec.configure do |config| | |
config.before :each do | |
stub_request(:any, /localhost:9200/).to_return(body: "<html>a webpage!</html>", status: 200) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thanks for this snippet. Could you please add some more comment to be clear, so other at beginner level would be easy to follow ?
The stub_request belong to the webmock gem. It's took me a while to figure out why it's wrong.
Add the following line in spec/spec_helper