I added the webmock gem to my Gemfile, I ran bundle and finally created the features/support/webmock.rb file with the following:
require 'webmock/cucumber'
Running the tests using $(which bundle) exec cucumber -p ios failed with the following :
Real HTTP connections are disabled. Unregistered request: POST http://127.0.0.1:37265/exit with body '{"post_resign_active_delay":0.4,"post_will_terminate_delay":0.4,"exit_code":0}' with headers {'Accept'=>'*/*', 'Content-Type'=>'application/x-www-form-urlencoded', 'Date'=>'Fri, 08 Jun 2018 12:55:16 GMT', 'User-Agent'=>'HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))'}
You can stub this request with the following snippet:
stub_request(:post, "http://127.0.0.1:37265/exit").
with(
body: {"{\"post_resign_active_delay\":0.4,\"post_will_terminate_delay\":0.4,\"exit_code\":0}"=>nil},
headers: {
'Accept'=>'*/*',
'Content-Type'=>'application/x-www-form-urlencoded',
'Date'=>'Fri, 08 Jun 2018 12:55:16 GMT',
'User-Agent'=>'HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))'
}).
to_return(status: 200, body: "", headers: {})
============================================================ (WebMock::NetConnectNotAllowedError)
./features/support/ios/01_launch.rb:41:in `After'
Nice ! 😎 it's working ! Let's allow localhost !
I updated the features/support/webmock.rb file as the following :
I added the webmock gem to my
Gemfile
, I ranbundle
and finally created thefeatures/support/webmock.rb
file with the following:Running the tests using
$(which bundle) exec cucumber -p ios
failed with the following :Nice ! 😎 it's working ! Let's allow localhost !
I updated the
features/support/webmock.rb
file as the following :But now when I run again the tests, it is failing with :
It would mean Calabash isn't compatible with WebMock 😢. Anything you know about Webmock and Calabash together?