Disable new_google_recaptcha for test cases
narender2031 opened this issue · 3 comments
narender2031 commented
error:
WebMock::NetConnectNotAllowedError:
Real HTTP connections are disabled. Unregistered request: GET https://www.google.com/recaptcha/api/siteverify?response=&secret=6LfHB7kUAAAAAHTFLRZDh6o23ICu86HbLUXB_Ric with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'www.google.com', 'User-Agent'=>'Ruby'}
You can stub this request with the following snippet:
stub_request(:get, "https://www.google.com/recaptcha/api/siteverify?response=&secret=6LfHB7kUAAAAAHTFLRZDh6o23ICu86HbLUXB_Ric").
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'www.google.com', 'User-Agent'=>'Ruby'}).
to_return(status: 200, body: "", headers: {})
How to add this in rails_helper.rb
module NewGoogleRecaptcha
def self.human?(*attrs)
true
end
end
adelnabiullin commented
@narender2031
Just add that code to the end of spec/rails_helper.rb
like this:
RSpec.configure do |config|
...
end
module NewGoogleRecaptcha
def self.human?(*attrs)
true
end
end
igorkasyanchuk commented
Can someone create a PR with a fix?
adelnabiullin commented
@igorkasyanchuk what do you mean?
do you want to disable recaptcha requests in a test environment by default?