watir-rails 2.0.0 → 2.2.3
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 +5 -5
- data/.gitignore +0 -0
- data/.travis.yml +4 -4
- data/.yardopts +0 -0
- data/CHANGES.md +58 -37
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/gemfiles/Gemfile.rails-2.x +0 -0
- data/gemfiles/Gemfile.rails-3.x +0 -0
- data/gemfiles/Gemfile.rails-4.x +6 -0
- data/lib/watir/rails.rb +31 -19
- data/lib/watir/rails/browser.rb +0 -0
- data/lib/watir/rails/middleware.rb +50 -26
- data/lib/watir/{version.rb → rails/version.rb} +5 -5
- data/spec/spec_helper.rb +0 -0
- data/spec/support/watir.rb +0 -0
- data/spec/watir/rails/browser_spec.rb +0 -0
- data/spec/watir/rails/middleware_spec.rb +0 -0
- data/spec/watir/rails_spec.rb +20 -3
- data/watir-rails.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '0890e02a5cef434105541f81252240ad701f28bb828643f84aaf6b6745eb6cbf'
|
4
|
+
data.tar.gz: b13169b1ea1a2bbfa49b79968eb5568e3137e2319e48a5172e70ab7f0f50572d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa0f04dfa0f53060fd48765c040f26158e647254bc9ca049c8ebc2bca4f89ef3bd2c117c7ccc2bc9c05a94b1a4a4c47a04c2f93eda59aeb835d72963d6624d7
|
7
|
+
data.tar.gz: 264a48bb5458b09926950e32709184d909ce4e15123e90bc8ff2ae0f6091c16f4e1aab39b2d421ba1f087f86a7ae9f3f5cf59bfbcb4c352ab9b95b39830b8c16
|
data/.gitignore
CHANGED
File without changes
|
data/.travis.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
rvm:
|
2
|
-
|
3
|
-
-
|
4
|
-
- ruby-head
|
2
|
+
- 2.6.3
|
3
|
+
- ruby-head
|
5
4
|
gemfile:
|
6
5
|
- gemfiles/Gemfile.rails-2.x
|
7
6
|
- gemfiles/Gemfile.rails-3.x
|
7
|
+
- gemfiles/Gemfile.rails-4.x
|
8
8
|
- Gemfile
|
9
9
|
notifications:
|
10
10
|
recipients:
|
11
|
-
- jarmo
|
11
|
+
- jarmo@jarmopertman.com
|
12
12
|
matrix:
|
13
13
|
allow_failures:
|
14
14
|
- rvm: ruby-head
|
data/.yardopts
CHANGED
File without changes
|
data/CHANGES.md
CHANGED
@@ -1,37 +1,58 @@
|
|
1
|
-
### 2.
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
###
|
6
|
-
|
7
|
-
* Fix
|
8
|
-
|
9
|
-
###
|
10
|
-
|
11
|
-
*
|
12
|
-
|
13
|
-
###
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
*
|
37
|
-
|
1
|
+
### 2.2.3 - 2021/04/16
|
2
|
+
|
3
|
+
* Fix a possible initialization problem with Watir 7.0.0+. See #32.
|
4
|
+
|
5
|
+
### 2.2.2 - 2020/06/04
|
6
|
+
|
7
|
+
* Fix a situation where checking if server is running without using specified port. PR #27 by Stefan Rotariu.
|
8
|
+
|
9
|
+
### 2.2.1 - 2019/05/12
|
10
|
+
|
11
|
+
* Fix EOFError on some environments. PR #25 by Slava Kardakov.
|
12
|
+
|
13
|
+
### 2.2.0 - 2019/05/08
|
14
|
+
|
15
|
+
* Add support for specifying custom server for test Rails instance. PR #23 by Alex Rodionov.
|
16
|
+
* Add support for cleaning up when test Rails server instance has served all requests. PR #23 by Alex Rodionov.
|
17
|
+
|
18
|
+
### 2.1.0 - 2019/03/19
|
19
|
+
|
20
|
+
* Add support for specifying Rails test-server port. PR #22 by Bartek Wilczek.
|
21
|
+
|
22
|
+
### 2.0.0 - 2016/09/24
|
23
|
+
|
24
|
+
* Add support for Watir 6.0.
|
25
|
+
|
26
|
+
### 1.2.1 - 2016/06/15
|
27
|
+
|
28
|
+
* Fix Browser#add_checker deprecation warning. PR #18 by Christophe Bliard.
|
29
|
+
|
30
|
+
### 1.2.0 - 2016/01/16
|
31
|
+
|
32
|
+
* Add support for running Rails on Puma server. PR #15 by Andrey Koleshko.
|
33
|
+
|
34
|
+
### 1.1.0 - 2015/07/22
|
35
|
+
|
36
|
+
* Remove strict `mime-types` dependency. See #13
|
37
|
+
|
38
|
+
### 1.0.4 - 2015/02/28
|
39
|
+
|
40
|
+
* Allow to set Watir::Rails.ignore_exceptions to false. PR #8 by Andrey Koleshko.
|
41
|
+
|
42
|
+
### 1.0.3 - 2013/11/02
|
43
|
+
|
44
|
+
* Make watir-rails working with Rails 2.3.x too.
|
45
|
+
|
46
|
+
### 1.0.2 - 2013/11/02
|
47
|
+
|
48
|
+
* Make sure that newest Rails is going to be installed on an empty system.
|
49
|
+
|
50
|
+
### 1.0.1 - 2013/11/01
|
51
|
+
|
52
|
+
* Add license to gemspec.
|
53
|
+
|
54
|
+
### 1.0.0 - 2013/10/05
|
55
|
+
|
56
|
+
* Add watir as a dependency to make it possible to use with watir-classic too.
|
57
|
+
* Add specs to keep the quality high.
|
58
|
+
* Documentation fixes.
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/gemfiles/Gemfile.rails-2.x
CHANGED
File without changes
|
data/gemfiles/Gemfile.rails-3.x
CHANGED
File without changes
|
data/lib/watir/rails.rb
CHANGED
@@ -18,17 +18,20 @@ module Watir
|
|
18
18
|
class << self
|
19
19
|
private :new
|
20
20
|
attr_reader :port, :middleware
|
21
|
-
attr_writer :ignore_exceptions
|
21
|
+
attr_writer :ignore_exceptions, :server
|
22
22
|
|
23
23
|
# Start the Rails server for tests.
|
24
24
|
# Will be called automatically by {Watir::Browser#initialize}.
|
25
|
-
|
25
|
+
#
|
26
|
+
# @param [Integer] port port for the Rails up to run on. If omitted random port will be picked.
|
27
|
+
def boot(port: nil)
|
28
|
+
@port = port || find_available_port
|
29
|
+
|
26
30
|
unless running?
|
27
31
|
@middleware = Middleware.new(app)
|
28
|
-
@port = find_available_port
|
29
32
|
|
30
33
|
@server_thread = Thread.new do
|
31
|
-
|
34
|
+
server.call @middleware, @port
|
32
35
|
end
|
33
36
|
|
34
37
|
Timeout.timeout(boot_timeout) { @server_thread.join(0.1) until running? }
|
@@ -65,6 +68,13 @@ module Watir
|
|
65
68
|
@middleware.error
|
66
69
|
end
|
67
70
|
|
71
|
+
# Returns true if there are pending requests to server.
|
72
|
+
#
|
73
|
+
# @return [Boolean]
|
74
|
+
def pending_requests?
|
75
|
+
@middleware.pending_requests?
|
76
|
+
end
|
77
|
+
|
68
78
|
# Set error rescued by the middleware.
|
69
79
|
#
|
70
80
|
# @param value
|
@@ -103,7 +113,7 @@ module Watir
|
|
103
113
|
if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
|
104
114
|
return res.body == @app.object_id.to_s
|
105
115
|
end
|
106
|
-
rescue Errno::ECONNREFUSED, Errno::EBADF
|
116
|
+
rescue Errno::ECONNREFUSED, Errno::EBADF, EOFError
|
107
117
|
return false
|
108
118
|
end
|
109
119
|
|
@@ -137,22 +147,24 @@ module Watir
|
|
137
147
|
server.close if server
|
138
148
|
end
|
139
149
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
def server
|
151
|
+
@server ||= lambda do |app, port|
|
152
|
+
begin
|
153
|
+
require 'rack/handler/thin'
|
154
|
+
Thin::Logging.silent = true
|
155
|
+
return Rack::Handler::Thin.run(app, :Port => port)
|
156
|
+
rescue LoadError
|
157
|
+
end
|
147
158
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
159
|
+
begin
|
160
|
+
require 'rack/handler/puma'
|
161
|
+
return Rack::Handler::Puma.run(app, :Port => port, :Silent => true)
|
162
|
+
rescue LoadError
|
163
|
+
end
|
153
164
|
|
154
|
-
|
155
|
-
|
165
|
+
require 'rack/handler/webrick'
|
166
|
+
Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
|
167
|
+
end
|
156
168
|
end
|
157
169
|
|
158
170
|
def legacy_rails?
|
data/lib/watir/rails/browser.rb
CHANGED
File without changes
|
@@ -1,26 +1,50 @@
|
|
1
|
-
module Watir
|
2
|
-
class Rails
|
3
|
-
# @private
|
4
|
-
class Middleware
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
module Watir
|
2
|
+
class Rails
|
3
|
+
# @private
|
4
|
+
class Middleware
|
5
|
+
class PendingRequestsCounter
|
6
|
+
attr_reader :value
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@value = 0
|
10
|
+
@mutex = Mutex.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def increment
|
14
|
+
@mutex.synchronize { @value += 1 }
|
15
|
+
end
|
16
|
+
|
17
|
+
def decrement
|
18
|
+
@mutex.synchronize { @value -= 1 }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :error
|
23
|
+
|
24
|
+
def initialize(app)
|
25
|
+
@app = app
|
26
|
+
@counter = PendingRequestsCounter.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def pending_requests?
|
30
|
+
@counter.value > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(env)
|
34
|
+
if env["PATH_INFO"] == "/__identify__"
|
35
|
+
[200, {}, [@app.object_id.to_s]]
|
36
|
+
else
|
37
|
+
@counter.increment
|
38
|
+
begin
|
39
|
+
@app.call(env)
|
40
|
+
rescue => e
|
41
|
+
@error = e
|
42
|
+
raise e
|
43
|
+
ensure
|
44
|
+
@counter.decrement
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Watir
|
2
|
-
class Rails
|
3
|
-
VERSION = "2.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Watir
|
2
|
+
class Rails
|
3
|
+
VERSION = "2.2.3"
|
4
|
+
end
|
5
|
+
end
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
data/spec/support/watir.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/watir/rails_spec.rb
CHANGED
@@ -9,9 +9,11 @@ describe Watir::Rails do
|
|
9
9
|
|
10
10
|
context ".boot" do
|
11
11
|
it "starts the server unless already running" do
|
12
|
+
server = ->(app, port) {}
|
12
13
|
allow(described_class).to receive_messages(app: double("app"), find_available_port: 42)
|
13
14
|
expect(described_class).to receive(:running?).twice.and_return(false, true)
|
14
|
-
expect(described_class).to receive(:
|
15
|
+
expect(described_class).to receive(:server).and_return(server)
|
16
|
+
expect(server).to receive(:call).once
|
15
17
|
|
16
18
|
described_class.boot
|
17
19
|
wait_until_server_started
|
@@ -20,16 +22,18 @@ describe Watir::Rails do
|
|
20
22
|
it "does nothing if server is already running" do
|
21
23
|
allow(described_class).to receive_messages(app: double("app"), find_available_port: 42)
|
22
24
|
expect(described_class).to receive(:running?).once.and_return(true)
|
23
|
-
expect(described_class).not_to receive(:
|
25
|
+
expect(described_class).not_to receive(:server)
|
24
26
|
|
25
27
|
described_class.boot
|
26
28
|
end
|
27
29
|
|
28
30
|
it "raises an error if Rails won't boot with timeout" do
|
31
|
+
server = ->(app, port) {}
|
29
32
|
allow(described_class).to receive_messages(app: double("app"),
|
30
33
|
find_available_port: 42, boot_timeout: 0.01)
|
31
34
|
expect(described_class).to receive(:running?).at_least(:twice).and_return(false)
|
32
|
-
expect(described_class).to receive(:
|
35
|
+
expect(described_class).to receive(:server).and_return(server)
|
36
|
+
expect(server).to receive(:call)
|
33
37
|
|
34
38
|
expect {
|
35
39
|
described_class.boot
|
@@ -41,6 +45,19 @@ describe Watir::Rails do
|
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
48
|
+
context ".server" do
|
49
|
+
it "allows to customize server" do
|
50
|
+
allow(described_class).to receive_messages(app: double("app"), find_available_port: 42)
|
51
|
+
allow(described_class).to receive(:running?).twice.and_return(false, true)
|
52
|
+
|
53
|
+
server = ->(app, port) {}
|
54
|
+
described_class.server = server
|
55
|
+
expect(server).to receive(:call)
|
56
|
+
|
57
|
+
described_class.boot
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
44
61
|
context ".host" do
|
45
62
|
it "@host if specified" do
|
46
63
|
described_class.host = "my_host"
|
data/watir-rails.gemspec
CHANGED
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.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarmo Pertman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -111,10 +111,11 @@ files:
|
|
111
111
|
- Rakefile
|
112
112
|
- gemfiles/Gemfile.rails-2.x
|
113
113
|
- gemfiles/Gemfile.rails-3.x
|
114
|
+
- gemfiles/Gemfile.rails-4.x
|
114
115
|
- lib/watir/rails.rb
|
115
116
|
- lib/watir/rails/browser.rb
|
116
117
|
- lib/watir/rails/middleware.rb
|
117
|
-
- lib/watir/version.rb
|
118
|
+
- lib/watir/rails/version.rb
|
118
119
|
- spec/spec_helper.rb
|
119
120
|
- spec/support/watir.rb
|
120
121
|
- spec/watir/rails/browser_spec.rb
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
144
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.6.
|
145
|
+
rubygems_version: 2.7.6.2
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: Use Watir (http://github.com/watir/watir) in Rails.
|
@@ -151,4 +152,3 @@ test_files:
|
|
151
152
|
- spec/watir/rails/browser_spec.rb
|
152
153
|
- spec/watir/rails/middleware_spec.rb
|
153
154
|
- spec/watir/rails_spec.rb
|
154
|
-
has_rdoc:
|