← Back to Upcase

Stub Request not working


(Lee Smith) #1

I am trying elasticsearch with the tire gem. But when adding the callbacks to my model it breaks rspec.

Here is a gist of my model(concern) and the error its producing.

I have put the stub_request in a file under spec/support called tire_webmock.rb

Whatever I do I can get past this error. Any advise on what I can do next?

I think it’s webmock which is not picking up the stub. But looking at webmock it looks like what I have done is correct.


(Lee Smith) #2

I have fixed it by adding changing the spec_helper.rb,

Basically I moved the require ‘webmock/rspec’ to the top then using the stub before anything else.

All sorted.


(Lee Smith) #3

Wrong, I still got issues running rspec.

Any ideas would be welcome.


(Chad Pytel) #4

Are you saying that its now failing intermittently or is still fails all the time?


(Lee Smith) #5

Will I got it working when running rspec. But then when using Guard with Spork it still continued to be a problem. But I have just added the moc to the Spork.each_run area and looks to be resolved.

I may move to zeus instead of Spork.

So for now it looks like im working again.


(Lee Smith) #6

Thanks to a lengthy chat with Joe the problem has been resolved. the following steps were done.

1, Remove Spork
2, Update Spec Helper

ENV["RAILS_ENV"] ||= 'test'
# change to
ENV['RAILS_ENV'] = 'test'

# moved require statement to top and add webmock
require 'webmock/rspec'
WebMock.disable_net_connect!(:allow_localhost => true)

# removed line
require 'rspec/autorun'

3, Added my vcr_helper.rb to autoload path. /spec/support

Seems so little in the ned but we went through many steps to get there.

Thank You Joe!!


(Ben Orenstein) #7

Thanks for following up and posting the solution! Nice forum etiquette :slight_smile: