watir-rails 2.2.3 → 2.4.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: '0890e02a5cef434105541f81252240ad701f28bb828643f84aaf6b6745eb6cbf'
4
- data.tar.gz: b13169b1ea1a2bbfa49b79968eb5568e3137e2319e48a5172e70ab7f0f50572d
3
+ metadata.gz: f3f4596aba0f22d5d0b00aeeb2bcb5b27235b573675eef6b34e41b1bdfca8592
4
+ data.tar.gz: 7e60e1cf800f2e2603566d81c25fa946c674903b6550594142c3ad8feca17d57
5
5
  SHA512:
6
- metadata.gz: 9aa0f04dfa0f53060fd48765c040f26158e647254bc9ca049c8ebc2bca4f89ef3bd2c117c7ccc2bc9c05a94b1a4a4c47a04c2f93eda59aeb835d72963d6624d7
7
- data.tar.gz: 264a48bb5458b09926950e32709184d909ce4e15123e90bc8ff2ae0f6091c16f4e1aab39b2d421ba1f087f86a7ae9f3f5cf59bfbcb4c352ab9b95b39830b8c16
6
+ metadata.gz: 7f92b51730934fa6dfa1726413802d5a358f93583263f2a65099075f3c4c06e959d75c0449365a6040e48b7f29618046bea46ab79ee361e535bc99d5eb5e0925
7
+ data.tar.gz: b250aa4862442974c4b1d8b0af79206deaeb9c94ac2f901c70ed4ce8a281101e8ff0f727e63d8b107c82b5092c2590e8971f39f3cbe1d757d2b948da8840ed92
@@ -0,0 +1,53 @@
1
+ name: Run watir-rails CI
2
+
3
+ 'on':
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-20.04
12
+ continue-on-error: ${{ matrix.ruby-version == 'debug' }}
13
+ strategy:
14
+ matrix:
15
+ BUNDLE_GEMFILE: [gemfiles/Gemfile.rails-3.x, gemfiles/Gemfile.rails-4.x, Gemfile]
16
+ ruby-version: [2.6.3, debug]
17
+ exclude:
18
+ # rails-4.2 requires BigDecimal.new (dropped in ruby-2.7)
19
+ - { BUNDLE_GEMFILE: gemfiles/Gemfile.rails-4.x, ruby-version: debug }
20
+ # The issue on rails-3.2 + head is json-1.8.6 compat (simplecov
21
+ # uses it), we could potentially workaround it using, for example, Oj
22
+ - { BUNDLE_GEMFILE: gemfiles/Gemfile.rails-3.x, ruby-version: debug }
23
+ env:
24
+ BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.BUNDLE_GEMFILE }}
25
+ LCOV_REPORT_PATH: './coverage/lcov.info'
26
+
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ # rails < 5 doesn't support bundler-2
34
+ bundler: 1
35
+ bundler-cache: true
36
+
37
+ - run: bundle exec rake
38
+
39
+ - uses: coverallsapp/github-action@master
40
+ with:
41
+ github-token: ${{ secrets.GITHUB_TOKEN }}
42
+ path-to-lcov: ${{ env.LCOV_REPORT_PATH }}
43
+ parallel: true
44
+ flag-name: ruby-${{ matrix.ruby-version }}_gemfile-${{ matrix.BUNDLE_GEMFILE }}
45
+
46
+ coveralls:
47
+ needs: test
48
+ runs-on: ubuntu-20.04
49
+ steps:
50
+ - uses: coverallsapp/github-action@master
51
+ with:
52
+ github-token: ${{ secrets.GITHUB_TOKEN }}
53
+ parallel-finished: true
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@ rvm:
2
2
  - 2.6.3
3
3
  - ruby-head
4
4
  gemfile:
5
- - gemfiles/Gemfile.rails-2.x
6
5
  - gemfiles/Gemfile.rails-3.x
7
6
  - gemfiles/Gemfile.rails-4.x
8
7
  - Gemfile
@@ -12,4 +11,3 @@ notifications:
12
11
  matrix:
13
12
  allow_failures:
14
13
  - rvm: ruby-head
15
-
data/CHANGES.md CHANGED
@@ -1,7 +1,15 @@
1
+ ### 2.4.0 - 2025/10/03
2
+
3
+ * Support Webrick for Ruby 3.0+. PR #37 by Norbert Szivós.
4
+
5
+ ### 2.3.0 - 2023/02/18
6
+
7
+ * Make `Watir::Rails.boot` use previously selected port in subsequent calls. PR #34 by Bartek Bulat.
8
+
1
9
  ### 2.2.3 - 2021/04/16
2
10
 
3
11
  * Fix a possible initialization problem with Watir 7.0.0+. See #32.
4
-
12
+
5
13
  ### 2.2.2 - 2020/06/04
6
14
 
7
15
  * Fix a situation where checking if server is running without using specified port. PR #27 by Stefan Rotariu.
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "coveralls", require: false
5
+ gem "simplecov", require: false
6
+ gem "simplecov-lcov", require: false
@@ -2,5 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: ".."
4
4
 
5
- gem "coveralls", require: false
6
- gem "rails", "~> 3.0"
5
+ gem "simplecov", require: false
6
+ gem "simplecov-lcov", require: false
7
+ gem "rails", "~> 3.0"
@@ -2,5 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: ".."
4
4
 
5
- gem "coveralls", require: false
5
+ gem "simplecov", require: false
6
+ gem "simplecov-lcov", require: false
6
7
  gem "rails", "~> 4.0"
@@ -1,5 +1,5 @@
1
1
  module Watir
2
2
  class Rails
3
- VERSION = "2.2.3"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
data/lib/watir/rails.rb CHANGED
@@ -3,12 +3,7 @@ require "net/http"
3
3
  require "rack"
4
4
  require "watir"
5
5
 
6
- begin
7
- require "rails"
8
- rescue LoadError
9
- # Load legacy Rails
10
- require "initializer"
11
- end
6
+ require "rails"
12
7
 
13
8
  require File.expand_path("rails/browser.rb", File.dirname(__FILE__))
14
9
  require File.expand_path("rails/middleware.rb", File.dirname(__FILE__))
@@ -23,9 +18,10 @@ module Watir
23
18
  # Start the Rails server for tests.
24
19
  # Will be called automatically by {Watir::Browser#initialize}.
25
20
  #
26
- # @param [Integer] port port for the Rails up to run on. If omitted random port will be picked.
21
+ # @param [Integer] port port for the Rails up to run on. If omitted use
22
+ # previously selected port or select random available port.
27
23
  def boot(port: nil)
28
- @port = port || find_available_port
24
+ @port = port || @port || find_available_port
29
25
 
30
26
  unless running?
31
27
  @middleware = Middleware.new(app)
@@ -87,13 +83,7 @@ module Watir
87
83
  # @return [Boolean] true if exceptions should be ignored, false otherwise.
88
84
  def ignore_exceptions?
89
85
  if @ignore_exceptions.nil?
90
- show_exceptions = if legacy_rails?
91
- ::Rails.configuration.action_dispatch.show_exceptions
92
- else
93
- ::Rails.application.config.action_dispatch.show_exceptions
94
- end
95
-
96
- if show_exceptions
86
+ if ::Rails.application.config.action_dispatch.show_exceptions
97
87
  warn '[WARN] "action_dispatch.show_exceptions" is set to "true", disabling watir-rails exception catcher.'
98
88
  @ignore_exceptions = true
99
89
  end
@@ -121,15 +111,9 @@ module Watir
121
111
  #
122
112
  # @return [Object] Rails Rack app.
123
113
  def app
124
- legacy = legacy_rails?
125
114
  @app ||= Rack::Builder.new do
126
115
  map "/" do
127
- if legacy
128
- use ::Rails::Rack::Static
129
- run ActionController::Dispatcher.new
130
- else
131
- run ::Rails.application
132
- end
116
+ run ::Rails.application
133
117
  end
134
118
  end.to_app
135
119
  end
@@ -162,15 +146,16 @@ module Watir
162
146
  rescue LoadError
163
147
  end
164
148
 
165
- require 'rack/handler/webrick'
166
- Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
167
- end
168
- end
149
+ begin
150
+ require 'rack/handler/webrick'
151
+ return Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
152
+ rescue LoadError
153
+ end
169
154
 
170
- def legacy_rails?
171
- ::Rails.version.to_f < 3.0
155
+ require 'rackup/handler/webrick'
156
+ Rackup::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
157
+ end
172
158
  end
173
-
174
159
  end
175
160
  end
176
161
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,17 @@
1
1
  require "simplecov"
2
- require 'coveralls'
3
2
 
4
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
3
+ if ENV["LCOV_REPORT_PATH"]
4
+ require "simplecov-lcov"
5
+
6
+ SimpleCov::Formatter::LcovFormatter.config do |c|
7
+ c.report_with_single_file = true
8
+ root_dir = File.expand_path('..', __dir__)
9
+ c.single_report_path = File.expand_path(ENV.fetch('LCOV_REPORT_PATH'), root_dir)
10
+ end
11
+
12
+ SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
13
+ end
14
+
5
15
  SimpleCov.start
6
16
 
7
17
  # Make sure that fake watir gems are loaded for specs.
@@ -12,4 +22,11 @@ require "watir/rails"
12
22
  RSpec.configure do |c|
13
23
  c.color = true
14
24
  c.order = :random
25
+
26
+ c.after do
27
+ described_class.instance_variable_set(:@port, nil)
28
+ described_class.instance_variable_set(:@server_thread, nil)
29
+ described_class.instance_variable_set(:@server, nil)
30
+ described_class.instance_variable_set(:@app, nil)
31
+ end
15
32
  end
@@ -24,6 +24,21 @@ describe Watir::Browser do
24
24
  expect_any_instance_of(Watir::Browser).to receive(:add_exception_hook)
25
25
  Watir::Browser.new
26
26
  end
27
+
28
+ context 'when boot was already called' do
29
+ let(:app) { -> (_env) { [200, {}, 'OK'] } }
30
+ before do
31
+ Watir::Rails.instance_variable_set(:@app, app)
32
+ Watir::Rails.boot
33
+ end
34
+
35
+ it 'does not start new server thread' do
36
+ middleware = Watir::Rails.middleware
37
+
38
+ Watir::Browser.new
39
+ expect(middleware).to eq(Watir::Rails.middleware)
40
+ end
41
+ end
27
42
  end
28
43
 
29
44
  context "#goto" do
@@ -7,6 +7,8 @@ describe Watir::Rails do
7
7
  described_class.instance_eval { @middleware = @port = @server_thread = @host = @app = nil }
8
8
  end
9
9
 
10
+ let(:thread) { described_class.instance_variable_get(:@server_thread) }
11
+
10
12
  context ".boot" do
11
13
  it "starts the server unless already running" do
12
14
  server = ->(app, port) {}
@@ -16,7 +18,8 @@ describe Watir::Rails do
16
18
  expect(server).to receive(:call).once
17
19
 
18
20
  described_class.boot
19
- wait_until_server_started
21
+
22
+ thread.join(10) || raise("Server thread not finished")
20
23
  end
21
24
 
22
25
  it "does nothing if server is already running" do
@@ -39,22 +42,21 @@ describe Watir::Rails do
39
42
  described_class.boot
40
43
  }.to raise_error(Timeout::Error)
41
44
  end
42
-
43
- def wait_until_server_started
44
- Timeout.timeout(10) { sleep 0.1 while described_class.instance_variable_get(:@server_thread).alive? }
45
- end
46
45
  end
47
46
 
48
47
  context ".server" do
48
+ let(:server) { ->(app, port) {} }
49
+
49
50
  it "allows to customize server" do
50
51
  allow(described_class).to receive_messages(app: double("app"), find_available_port: 42)
51
52
  allow(described_class).to receive(:running?).twice.and_return(false, true)
52
53
 
53
- server = ->(app, port) {}
54
54
  described_class.server = server
55
55
  expect(server).to receive(:call)
56
56
 
57
57
  described_class.boot
58
+
59
+ thread.join(10) || raise("Server thread not finished")
58
60
  end
59
61
  end
60
62
 
@@ -81,17 +83,7 @@ describe Watir::Rails do
81
83
  expect(described_class).not_to be_ignore_exceptions
82
84
  end
83
85
 
84
- it "true if Rails.action_dispatch.show_exceptions is set to true for older Rails" do
85
- allow(described_class).to receive_messages(legacy_rails?: true)
86
- described_class.ignore_exceptions = nil
87
- allow(::Rails).to receive_message_chain(:configuration,
88
- :action_dispatch, :show_exceptions).and_return(true)
89
-
90
- expect(described_class).to be_ignore_exceptions
91
- end
92
-
93
- it "true if Rails.action_dispatch.show_exceptions is set to true for Rails 3" do
94
- allow(described_class).to receive_messages(legacy_rails?: false)
86
+ it "true if Rails.action_dispatch.show_exceptions is set to true" do
95
87
  described_class.ignore_exceptions = nil
96
88
  allow(::Rails).to receive_message_chain(:application,
97
89
  :config, :action_dispatch, :show_exceptions).and_return(true)
@@ -99,17 +91,7 @@ describe Watir::Rails do
99
91
  expect(described_class).to be_ignore_exceptions
100
92
  end
101
93
 
102
- it "false if Rails.action_dispatch.show_exceptions is set to false for older Rails" do
103
- allow(described_class).to receive_messages(legacy_rails?: true)
104
- described_class.ignore_exceptions = nil
105
- allow(::Rails).to receive_message_chain(:configuration,
106
- :action_dispatch, :show_exceptions).and_return(false)
107
-
108
- expect(described_class).not_to be_ignore_exceptions
109
- end
110
-
111
- it "true if Rails.action_dispatch.show_exceptions is set to false for Rails 3" do
112
- allow(described_class).to receive_messages(legacy_rails?: false)
94
+ it "true if Rails.action_dispatch.show_exceptions is set to false" do
113
95
  described_class.ignore_exceptions = nil
114
96
  allow(::Rails).to receive_message_chain(:application,
115
97
  :config, :action_dispatch, :show_exceptions).and_return(false)
data/watir-rails.gemspec CHANGED
@@ -1,26 +1,28 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/watir/rails/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Jarmo Pertman"]
6
- gem.email = ["jarmo.p@gmail.com"]
7
- gem.description = %q{Use Watir (http://github.com/watir/watir) in Rails.}
8
- gem.summary = %q{Use Watir (http://github.com/watir/watir) in Rails.}
9
- gem.homepage = "http://github.com/watir/watir-rails"
10
-
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "watir-rails"
15
- gem.require_paths = ["lib"]
16
- gem.license = "MIT"
17
- gem.version = Watir::Rails::VERSION
18
-
19
- gem.add_dependency "rack"
20
- gem.add_dependency "rails"
21
- gem.add_dependency "watir", ">= 6.0.0.beta4"
22
-
23
- gem.add_development_dependency "yard"
24
- gem.add_development_dependency "redcarpet"
25
- gem.add_development_dependency "rspec", "~> 3.0"
26
- end
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/watir/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jarmo Pertman"]
6
+ gem.email = ["jarmo.p@gmail.com"]
7
+ gem.description = %q{Use Watir (http://github.com/watir/watir) in Rails.}
8
+ gem.summary = %q{Use Watir (http://github.com/watir/watir) in Rails.}
9
+ gem.homepage = "http://github.com/watir/watir-rails"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "watir-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.license = "MIT"
17
+ gem.version = Watir::Rails::VERSION
18
+ gem.required_ruby_version = ">= 2.4.0"
19
+
20
+ gem.add_dependency "rack"
21
+ gem.add_dependency "rails", ">= 3"
22
+ gem.add_dependency "watir", ">= 6.0.0.beta4"
23
+
24
+ gem.add_development_dependency "yard"
25
+ gem.add_development_dependency "redcarpet"
26
+ gem.add_development_dependency "rspec", "~> 3.0"
27
+ gem.add_development_dependency "webrick"
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarmo Pertman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-16 00:00:00.000000000 Z
11
+ date: 2025-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: watir
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webrick
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Use Watir (http://github.com/watir/watir) in Rails.
98
112
  email:
99
113
  - jarmo.p@gmail.com
@@ -101,6 +115,7 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".github/workflows/ci.yml"
104
119
  - ".gitignore"
105
120
  - ".travis.yml"
106
121
  - ".yardopts"
@@ -109,7 +124,6 @@ files:
109
124
  - LICENSE
110
125
  - README.md
111
126
  - Rakefile
112
- - gemfiles/Gemfile.rails-2.x
113
127
  - gemfiles/Gemfile.rails-3.x
114
128
  - gemfiles/Gemfile.rails-4.x
115
129
  - lib/watir/rails.rb
@@ -134,15 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
148
  requirements:
135
149
  - - ">="
136
150
  - !ruby/object:Gem::Version
137
- version: '0'
151
+ version: 2.4.0
138
152
  required_rubygems_version: !ruby/object:Gem::Requirement
139
153
  requirements:
140
154
  - - ">="
141
155
  - !ruby/object:Gem::Version
142
156
  version: '0'
143
157
  requirements: []
144
- rubyforge_project:
145
- rubygems_version: 2.7.6.2
158
+ rubygems_version: 3.1.6
146
159
  signing_key:
147
160
  specification_version: 4
148
161
  summary: Use Watir (http://github.com/watir/watir) in Rails.
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec path: ".."
4
-
5
- gem "coveralls", require: false
6
- gem "rails", "~> 2.0"