Trying to get selenium working in rails 3 - “WebMock::NetConnectNotAllowedError”

后端 未结 8 1471
遥遥无期
遥遥无期 2020-12-13 14:10

I\'m trying to use selenium for the first time in a rails 3 app. (I\'ve used it before with rails 2). I\'m in an rvm which of course has its own gemset.

I first r

8条回答
  •  有刺的猬
    2020-12-13 14:27

    We use this to enable normal requests in capybara, and allow selenium's callbacks everywhere, because they are fired after requests are finished.

    # spec/spec_helper.rb
    RSpec.configure do |config|
      config.before(:all, type: :request) do
        WebMock.allow_net_connect!
      end  
    
      config.after(:all, type: :request) do
        selenium_requests = %r{/((__.+__)|(hub/session.*))$}
        WebMock.disable_net_connect! :allow => selenium_requests
      end
    end
    

提交回复
热议问题