Видеомагнитофон запускается только один раз для тестирования интеграции в капибаре с селеновым webkit

Я использую Rspec с Capybara, выполняющим интеграционные тесты с использованием VCR gem для имитации заглушек запросов API. Я сталкиваюсь с очень странной проблемой. Тест успешно выполняется в первый раз и создает файл yaml для сохранения запросов и их ответов. Но если я снова запускаю тест после создания файла yaml, он сталкивается с проблемой и показывает следующую проблему:-

F

Failures:

  1) AffiliateSignUpProcesses Sign up using affiliate link should create User/Affiliate/AffiliateToken and Conversion when user is created
     Failure/Error: visit pricing_path(:aid => 'this_is_sample_value')
     VCR::Errors::UnhandledHTTPRequestError:


       ================================================================================
       An HTTP request has been made that VCR does not know how to handle:
         GET http://127.0.0.1:58021/__identify__

       VCR is currently using the following cassette:
         - /home/pcname/appname/selenium-error/fildername/appaname/cassettes/acceptanceTest/AffiliateSignUpProcess.yml
         - :record => :once
         - :match_requests_on => [:method, :uri]

       Under the current configuration VCR can not find a suitable HTTP interaction
       to replay and is prevented from recording new requests. There are a few ways
       you can deal with this:

         * If you're surprised VCR is raising this error
           and want insight about how VCR attempted to handle the request,
           you can use the debug_logger configuration option to log more details [1].
         * You can use the :new_episodes record mode to allow VCR to
           record this new request to the existing cassette [2].
         * If you want VCR to ignore this request (and others like it), you can
           set an `ignore_request` callback [3].
         * The current record mode (:once) does not allow new requests to be recorded
           to a previously recorded cassette. You can delete the cassette file and re-run
           your tests to allow the cassette to be recorded with this request [4].
         * The cassette contains 64 HTTP interactions that have not been
           played back. If your request is non-deterministic, you may need to
           change your :match_requests_on cassette option to be more lenient
           or use a custom request matcher to allow it to match [5].

       [1] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/debug-logging
       [2] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/new-episodes
       [3] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/ignore-request
       [4] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/once
       [5] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/request-matching
       ================================================================================
     # ./spec/acceptance/affiliate_sign_up_processes_spec.rb:8:in `block (4 levels) in <top (required)>'
     # ./spec/acceptance/affiliate_sign_up_processes_spec.rb:6:in `block (3 levels) in <top (required)>'

Finished in 2.42 seconds
1 example, 1 failure

ниже мой vcr.rb:-

VCR.configure do |c|
  c.allow_http_connections_when_no_cassette = true
  c.hook_into :fakeweb
  c.cassette_library_dir     = 'cassettes'
end

И мой интеграционный тест:-

требует 'spec_helper'

describe "AffiliateSignUpProcesses", :js => true  do
  describe "Sign up using affiliate link" do
    it "should create User/Affiliate/AffiliateToken and Conversion when user is created" do
      VCR.use_cassette("acceptanceTest/AffiliateSignUpProcess", :record => :once) do
        visit pricing_path(:aid => 'this_is_sample_value')
        @email="static_for_vcr@testdomain.com"
        #and other code
      end
    end
  end
end

1 ответ

На самом деле он рассматривает все запросы localhost для "посещения" как вызовы API. Так что просто нужно их исправить, игнорируя запросы "localhost". Симпли напишите следующее в файле vcr.rb

c.ignore_localhost = true

Нашел здесь: - https://makandracards.com/ninjaconcept/tags/javascript?switch_to=pane

Более исчерпывающий: - https://www.relishapp.com/vcr/vcr/v/2-3-0/docs/configuration/ignore-request

Другие вопросы по тегам