watir-rails 2.1.0 → 2.2.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 +4 -4
- data/.travis.yml +2 -4
- data/CHANGES.md +46 -41
- data/lib/watir/rails.rb +25 -16
- data/lib/watir/rails/middleware.rb +50 -26
- data/lib/watir/version.rb +5 -5
- data/spec/watir/rails_spec.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a45f26d9da43e400198f49fc425cbe39a382631
|
4
|
+
data.tar.gz: ac2b52867c14b010cbebc456db6b2e4ccea2dd18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a99d40534ecb7e91f12c90f6c310253c3bd79c0955178c9ac67650e063fb84dc1b54d7418fa4c76b989dd3943c346d22966b74db7c0a6839f8c43ec09ab243
|
7
|
+
data.tar.gz: b05f51b501f5c6ed21efc0cebd5b3e74dd3c3bcea3de129bbec5175d625397f7d8b85e21970ce25e1616da69b2a8d6f90b319ad1efb5d92d51e207e586afe327
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,41 +1,46 @@
|
|
1
|
-
### 2.
|
2
|
-
|
3
|
-
* Add support for specifying
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
* Add
|
41
|
-
|
1
|
+
### 2.2.0 - 2019
|
2
|
+
|
3
|
+
* Add support for specifying custom server for test Rails instance. PR #23 by Alex Rodionov.
|
4
|
+
* Add support for cleaning up when test Rails server instance has served all requests. PR #23 by Alex Rodionov.
|
5
|
+
|
6
|
+
### 2.1.0 - 2019/03/19
|
7
|
+
|
8
|
+
* Add support for specifying Rails test-server port. PR #22 by Bartek Wilczek.
|
9
|
+
|
10
|
+
### 2.0.0 - 2016/09/24
|
11
|
+
|
12
|
+
* Add support for Watir 6.0.
|
13
|
+
|
14
|
+
### 1.2.1 - 2016/06/15
|
15
|
+
|
16
|
+
* Fix Browser#add_checker deprecation warning. PR #18 by Christophe Bliard.
|
17
|
+
|
18
|
+
### 1.2.0 - 2016/01/16
|
19
|
+
|
20
|
+
* Add support for running Rails on Puma server. PR #15 by Andrey Koleshko.
|
21
|
+
|
22
|
+
### 1.1.0 - 2015/07/22
|
23
|
+
|
24
|
+
* Remove strict `mime-types` dependency. See #13
|
25
|
+
|
26
|
+
### 1.0.4 - 2015/02/28
|
27
|
+
|
28
|
+
* Allow to set Watir::Rails.ignore_exceptions to false. PR #8 by Andrey Koleshko.
|
29
|
+
|
30
|
+
### 1.0.3 - 2013/11/02
|
31
|
+
|
32
|
+
* Make watir-rails working with Rails 2.3.x too.
|
33
|
+
|
34
|
+
### 1.0.2 - 2013/11/02
|
35
|
+
|
36
|
+
* Make sure that newest Rails is going to be installed on an empty system.
|
37
|
+
|
38
|
+
### 1.0.1 - 2013/11/01
|
39
|
+
|
40
|
+
* Add license to gemspec.
|
41
|
+
|
42
|
+
### 1.0.0 - 2013/10/05
|
43
|
+
|
44
|
+
* Add watir as a dependency to make it possible to use with watir-classic too.
|
45
|
+
* Add specs to keep the quality high.
|
46
|
+
* Documentation fixes.
|
data/lib/watir/rails.rb
CHANGED
@@ -18,7 +18,7 @@ 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}.
|
@@ -30,7 +30,7 @@ module Watir
|
|
30
30
|
@port = port || find_available_port
|
31
31
|
|
32
32
|
@server_thread = Thread.new do
|
33
|
-
|
33
|
+
server.call @middleware, @port
|
34
34
|
end
|
35
35
|
|
36
36
|
Timeout.timeout(boot_timeout) { @server_thread.join(0.1) until running? }
|
@@ -67,6 +67,13 @@ module Watir
|
|
67
67
|
@middleware.error
|
68
68
|
end
|
69
69
|
|
70
|
+
# Returns true if there are pending requests to server.
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
def pending_requests?
|
74
|
+
@middleware.pending_requests?
|
75
|
+
end
|
76
|
+
|
70
77
|
# Set error rescued by the middleware.
|
71
78
|
#
|
72
79
|
# @param value
|
@@ -139,22 +146,24 @@ module Watir
|
|
139
146
|
server.close if server
|
140
147
|
end
|
141
148
|
|
142
|
-
def
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
+
def server
|
150
|
+
@server ||= lambda do |app, port|
|
151
|
+
begin
|
152
|
+
require 'rack/handler/thin'
|
153
|
+
Thin::Logging.silent = true
|
154
|
+
return Rack::Handler::Thin.run(app, :Port => port)
|
155
|
+
rescue LoadError
|
156
|
+
end
|
149
157
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
158
|
+
begin
|
159
|
+
require 'rack/handler/puma'
|
160
|
+
return Rack::Handler::Puma.run(app, :Port => port, :Silent => true)
|
161
|
+
rescue LoadError
|
162
|
+
end
|
155
163
|
|
156
|
-
|
157
|
-
|
164
|
+
require 'rack/handler/webrick'
|
165
|
+
Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
|
166
|
+
end
|
158
167
|
end
|
159
168
|
|
160
169
|
def legacy_rails?
|
@@ -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
|
data/lib/watir/version.rb
CHANGED
@@ -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.0"
|
4
|
+
end
|
5
|
+
end
|
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"
|
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.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: 2019-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|