watir-rails 2.0.0 → 2.2.3

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
- SHA1:
3
- metadata.gz: 20dfc23f553782527d053042e02c2e58b2661c96
4
- data.tar.gz: 22654fad486f48652f1a184ece70a3d54352b444
2
+ SHA256:
3
+ metadata.gz: '0890e02a5cef434105541f81252240ad701f28bb828643f84aaf6b6745eb6cbf'
4
+ data.tar.gz: b13169b1ea1a2bbfa49b79968eb5568e3137e2319e48a5172e70ab7f0f50572d
5
5
  SHA512:
6
- metadata.gz: cd85bf3cf5e6a8c31d6f152f1deaece79d3519164f0bb608f9b6deb24dc57e1c0a1351651c606c7dbdf0c9142ad64bf58092510ce2a654b2ebcd9b43ac9cbbdc
7
- data.tar.gz: 90a968a7118048bb196507509a8e2e089e3ed668b8a23cb3353d0908a10f4596451708971d2f558347eb872eec947fc52e67169643026d0b773a3a45d5131c0d
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
- - 2.3.1
3
- - 2.2.5
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.p@gmail.com
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.0.0 - 2016/09/24
2
-
3
- * Add support for Watir 6.0.
4
-
5
- ### 1.2.1 - 2016/06/15
6
-
7
- * Fix Browser#add_checker deprecation warning. PR #18 by Christophe Bliard.
8
-
9
- ### 1.2.0 - 2016/01/16
10
-
11
- * Add support for running Rails on Puma server. PR #15 by Andrey Koleshko.
12
-
13
- ### 1.1.0 - 2015/07/22
14
-
15
- * Remove strict `mime-types` dependency. See #13
16
-
17
- ### 1.0.4 - 2015/02/28
18
-
19
- * Allow to set Watir::Rails.ignore_exceptions to false. PR #8 by Andrey Koleshko.
20
-
21
- ### 1.0.3 - 2013/11/02
22
-
23
- * Make watir-rails working with Rails 2.3.x too.
24
-
25
- ### 1.0.2 - 2013/11/02
26
-
27
- * Make sure that newest Rails is going to be installed on an empty system.
28
-
29
- ### 1.0.1 - 2013/11/01
30
-
31
- * Add license to gemspec.
32
-
33
- ### 1.0.0 - 2013/10/05
34
-
35
- * Add watir as a dependency to make it possible to use with watir-classic too.
36
- * Add specs to keep the quality high.
37
- * Documentation fixes.
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
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "coveralls", require: false
6
+ gem "rails", "~> 4.0"
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
- def boot
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
- run_default_server @middleware, @port
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 run_default_server(app, port)
141
- begin
142
- require 'rack/handler/thin'
143
- Thin::Logging.silent = true
144
- return Rack::Handler::Thin.run(app, :Port => port)
145
- rescue LoadError
146
- end
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
- begin
149
- require 'rack/handler/puma'
150
- return Rack::Handler::Puma.run(app, :Port => port, :Silent => true)
151
- rescue LoadError
152
- end
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
- require 'rack/handler/webrick'
155
- Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
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?
File without changes
@@ -1,26 +1,50 @@
1
- module Watir
2
- class Rails
3
- # @private
4
- class Middleware
5
- attr_accessor :error
6
-
7
- def initialize(app)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- if env["PATH_INFO"] == "/__identify__"
13
- [200, {}, [@app.object_id.to_s]]
14
- else
15
- begin
16
- @app.call(env)
17
- rescue => e
18
- @error = e
19
- raise e
20
- end
21
- end
22
- end
23
- end
24
-
25
- end
26
- end
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.0.0"
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
File without changes
File without changes
File without changes
@@ -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(:run_default_server).once
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(:run_default_server)
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(:run_default_server)
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
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/watir/version', __FILE__)
2
+ require File.expand_path('../lib/watir/rails/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Jarmo Pertman"]
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.0.0
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: 2016-09-24 00:00:00.000000000 Z
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.4
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: