igorkasyanchuk / new_google_recaptcha

reCAPTCHA v3 Ruby on Rails gem

Home Page:https://www.railsjazz.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable new_google_recaptcha for test cases

narender2031 opened this issue · comments

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

@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

Can someone create a PR with a fix?

@igorkasyanchuk what do you mean?
do you want to disable recaptcha requests in a test environment by default?