capybara-webmock 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 450b7bf5f02a330c0b16a782ea81808fe8377a6a338762b37aa035054316b4c2
4
- data.tar.gz: a8c2c65daee214cf9911d9fc1fdc9e39ad9e40d47b3b37df48c03ccd3505e5a2
3
+ metadata.gz: 28f4ebed6063f94e18d058d63223bd1c9fd437241e622cee85f38597122aca2b
4
+ data.tar.gz: debbbb2e0c9d47f31930781dc38e19b0dbd4bea58424b3325a25dd8d119c3e48
5
5
  SHA512:
6
- metadata.gz: 89aceae8564772edfc9c64ee4c88a25e7c0f747acd970fcad61f6f155c6332baf5d0f757440284ef5ab4a5ea32a9e5dfb92c9809be63a6291234960c1c4eb37c
7
- data.tar.gz: dc9ce238ba25cd475cd2eeb900f483bdfb6bc3b0763131c90326534d79133282ec5d98d7259e5599c5e1949e82feae989c26a1aaa7d897dbe8884cc4f1c32e6f
6
+ metadata.gz: 6f2a033ab751fd97ff1b8798ab87264625191a361619f6b70d9ef6e7323dd739cc0ca95401de958d821cd1511b7aa996060d7713ad7e7eb0f01d60b6e25f4dbb
7
+ data.tar.gz: f6e373337fee16aef5c716c9648103651905ca1e3996e67051f183b8f1c686de903be936b8dc5f627490ff935162bbd7efac0601b7df156ad1de4c01acc2d2e3
@@ -0,0 +1,25 @@
1
+ name: Run tests
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os: [ubuntu-latest, macos-latest]
11
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
12
+ ruby: [2.5, 2.6, 2.7, '3.0', head]
13
+ runs-on: ${{ matrix.os }}
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: nanasess/setup-chromedriver@master
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ - run: |
22
+ export DISPLAY=":99"
23
+ chromedriver --url-base=/wd/hub &
24
+ sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
25
+ bundle exec rake
data/README.md CHANGED
@@ -110,6 +110,13 @@ it 'makes a request to /somewhere when the user visits the page' do
110
110
  end
111
111
  ```
112
112
 
113
+ You can provide extra hosts to be permitted past the proxy, but should be used carefully.
114
+ This setting does not remove the default localhosts, but adds to them.
115
+
116
+ ```ruby
117
+ Capybara::Webmock.allowed_hosts = ["example.com", "sub.example.com"]
118
+ ```
119
+
113
120
  ### Development
114
121
 
115
122
  After pulling down the repo, install dependencies:
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "rack", ">= 1.4"
27
27
  spec.add_dependency "rack-proxy", ">= 0.6.0"
28
28
  spec.add_dependency "selenium-webdriver", "~> 3.0"
29
+ spec.add_dependency "rexml", ">= 3.2"
30
+ spec.add_dependency "webrick", ">= 1.7"
29
31
 
30
32
  spec.add_development_dependency "bundler", ">= 1.13"
31
33
  spec.add_development_dependency "pry", "~> 0.10.4"
@@ -9,15 +9,21 @@ require 'capybara/webmock/proxied_request'
9
9
 
10
10
  module Capybara
11
11
  module Webmock
12
+ SEPARATOR = "|"
13
+
12
14
  class << self
13
- attr_accessor :port_number, :pid_file, :kill_timeout, :start_timeout
15
+ attr_accessor :port_number, :pid_file, :kill_timeout, :start_timeout, :allowed_hosts
14
16
 
15
17
  def start
16
18
  if @pid.nil?
17
19
  kill_old_process
18
20
  gem_path = File.dirname(__FILE__)
19
21
  proxy_file = File.join(gem_path, 'webmock', 'config.ru')
20
- stdin, stdout, wait_thr = Open3.popen2e({ "PROXY_PORT_NUMBER" => port_number.to_s }, "rackup", proxy_file)
22
+ env_config = {
23
+ "CAPYBARA_WEBMOCK_PROXY_PORT_NUMBER" => port_number.to_s,
24
+ "CAPYBARA_WEBMOCK_ADDED_HOSTS" => allowed_hosts.to_a.join(SEPARATOR)
25
+ }
26
+ stdin, stdout, wait_thr = Open3.popen2e(env_config, "rackup", proxy_file)
21
27
  stdin.close
22
28
  @stdout = stdout
23
29
  @pid = wait_thr[:pid]
@@ -2,4 +2,4 @@ require 'rack'
2
2
  require 'capybara/webmock/proxy'
3
3
 
4
4
  app = Capybara::Webmock::Proxy.new(Process.pid)
5
- Rack::Handler::WEBrick.run(app, Port: ENV.fetch('PROXY_PORT_NUMBER', 9292))
5
+ Rack::Handler::WEBrick.run(app, Port: ENV.fetch('CAPYBARA_WEBMOCK_PROXY_PORT_NUMBER', 9292))
@@ -2,7 +2,7 @@ require 'rack/proxy'
2
2
  require 'capybara/webmock'
3
3
 
4
4
  class Capybara::Webmock::Proxy < Rack::Proxy
5
- ALLOWED_HOSTS = allowed_hosts = ['127.0.0.1', 'localhost', /(.*\.|\A)lvh.me/]
5
+ DEFAULT_ALLOWED_HOSTS = ['127.0.0.1', 'localhost', /(.*\.|\A)lvh.me/]
6
6
 
7
7
  def call(env)
8
8
  @streaming = true
@@ -27,8 +27,12 @@ class Capybara::Webmock::Proxy < Rack::Proxy
27
27
 
28
28
  private
29
29
 
30
+ def allowed_hosts
31
+ DEFAULT_ALLOWED_HOSTS + ENV.fetch('CAPYBARA_WEBMOCK_ADDED_HOSTS', "").split(Capybara::Webmock::SEPARATOR)
32
+ end
33
+
30
34
  def allowed_host?(host)
31
- ALLOWED_HOSTS.any? do |allowed_host|
35
+ allowed_hosts.any? do |allowed_host|
32
36
  case allowed_host
33
37
  when Regexp
34
38
  allowed_host =~ host
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Webmock
3
- VERSION = '0.5.5'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Worth
8
8
  - Dillon Hafer
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-08 00:00:00.000000000 Z
12
+ date: 2021-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -73,6 +73,34 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rexml
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3.2'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ - !ruby/object:Gem::Dependency
91
+ name: webrick
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '1.7'
76
104
  - !ruby/object:Gem::Dependency
77
105
  name: bundler
78
106
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +206,7 @@ executables: []
178
206
  extensions: []
179
207
  extra_rdoc_files: []
180
208
  files:
181
- - ".circleci/config.yml"
209
+ - ".github/workflows/run-tests.yml"
182
210
  - ".gitignore"
183
211
  - ".rspec"
184
212
  - CODE_OF_CONDUCT.md
@@ -198,7 +226,7 @@ homepage: https://github.com/hashrocket/capybara-webmock
198
226
  licenses:
199
227
  - MIT
200
228
  metadata: {}
201
- post_install_message:
229
+ post_install_message:
202
230
  rdoc_options: []
203
231
  require_paths:
204
232
  - lib
@@ -213,8 +241,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
241
  - !ruby/object:Gem::Version
214
242
  version: '0'
215
243
  requirements: []
216
- rubygems_version: 3.0.3
217
- signing_key:
244
+ rubygems_version: 3.2.3
245
+ signing_key:
218
246
  specification_version: 4
219
247
  summary: Mock external requests
220
248
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,9 +0,0 @@
1
- version: 2
2
- jobs:
3
- build:
4
- docker:
5
- - image: circleci/ruby:2.5.1-browsers
6
- steps:
7
- - checkout
8
- - run: bundle install
9
- - run: rake