capybara-webmock 0.5.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 450b7bf5f02a330c0b16a782ea81808fe8377a6a338762b37aa035054316b4c2
4
- data.tar.gz: a8c2c65daee214cf9911d9fc1fdc9e39ad9e40d47b3b37df48c03ccd3505e5a2
3
+ metadata.gz: b8379a3e56d9f89962f14ef02f2a9036666731a82bbcd0d39d2bdd12bad6e435
4
+ data.tar.gz: 31d3cc80d646135ee11f7397292392d63073a1bbbd378e5269321c0a18f665a9
5
5
  SHA512:
6
- metadata.gz: 89aceae8564772edfc9c64ee4c88a25e7c0f747acd970fcad61f6f155c6332baf5d0f757440284ef5ab4a5ea32a9e5dfb92c9809be63a6291234960c1c4eb37c
7
- data.tar.gz: dc9ce238ba25cd475cd2eeb900f483bdfb6bc3b0763131c90326534d79133282ec5d98d7259e5599c5e1949e82feae989c26a1aaa7d897dbe8884cc4f1c32e6f
6
+ metadata.gz: 927cc95692c0efec180d264d1c126408b1c454032ebdc8f5f0ed3c39ec60abf89348f9634310901f71bcb8dd75d8bdd2b49707b24eee27639ed5b17ebaa721f3
7
+ data.tar.gz: 927611b5c8b24e84a9031feb7fe5102ea0d07f15e551215d994a1c65865ca4d35b6f6acf9b09495de13e2fbb10238f9db2605d8cbf0cf500b8b76f7f6335b202
@@ -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.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:
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/hashrocket/capybara-webmock'
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.required_ruby_version = ">= 2.0.0"
17
+ spec.required_ruby_version = ">= 2.6.0"
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
20
  f.match(%r{^(test|spec|features)/})
@@ -25,7 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "capybara", ">= 2.4", "< 4"
26
26
  spec.add_dependency "rack", ">= 1.4"
27
27
  spec.add_dependency "rack-proxy", ">= 0.6.0"
28
- spec.add_dependency "selenium-webdriver", "~> 3.0"
28
+ spec.add_dependency "selenium-webdriver", ">= 4.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"
@@ -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.7.0'.freeze
4
4
  end
5
5
  end
@@ -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]
@@ -117,7 +123,7 @@ module Capybara
117
123
  end
118
124
 
119
125
  def kill_old_process
120
- return unless File.exists?(pid_file)
126
+ return unless File.exist?(pid_file)
121
127
  old_pid = File.read(pid_file).to_i
122
128
  kill_process(old_pid) if old_pid > 1
123
129
  remove_pid_file
@@ -146,13 +152,13 @@ module Capybara
146
152
  end
147
153
 
148
154
  def write_pid_file
149
- raise "Pid file #{pid_file} already exists" if File.exists?(pid_file)
155
+ raise "Pid file #{pid_file} already exists" if File.exist?(pid_file)
150
156
  FileUtils.mkdir_p(File.dirname(pid_file))
151
157
  File.write(pid_file, @pid.to_s)
152
158
  end
153
159
 
154
160
  def remove_pid_file
155
- File.delete(pid_file) if File.exists?(pid_file)
161
+ File.delete(pid_file) if File.exist?(pid_file)
156
162
  end
157
163
  end
158
164
  end
@@ -168,11 +174,11 @@ Capybara.register_driver :capybara_webmock do |app|
168
174
  end
169
175
 
170
176
  Capybara.register_driver :capybara_webmock_chrome do |app|
171
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: Capybara::Webmock.chrome_options)
177
+ Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: [Capybara::Webmock.chrome_options])
172
178
  end
173
179
 
174
180
  Capybara.register_driver :capybara_webmock_chrome_headless do |app|
175
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: Capybara::Webmock.chrome_headless_options)
181
+ Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: [Capybara::Webmock.chrome_headless_options])
176
182
  end
177
183
 
178
184
  Capybara.register_driver :capybara_webmock_poltergeist do |app|
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.7.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: 2023-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -63,16 +63,44 @@ dependencies:
63
63
  name: selenium-webdriver
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '4.0'
69
69
  type: :runtime
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '4.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
@@ -206,15 +234,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
234
  requirements:
207
235
  - - ">="
208
236
  - !ruby/object:Gem::Version
209
- version: 2.0.0
237
+ version: 2.6.0
210
238
  required_rubygems_version: !ruby/object:Gem::Requirement
211
239
  requirements:
212
240
  - - ">="
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.4.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