watir-rails 1.2.1 → 2.0.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
  SHA1:
3
- metadata.gz: ae7a57e6b5536cac083dfa83bffa44461bd34d0f
4
- data.tar.gz: 62d7d8fcf2a10ed6ca3ea85df33cb102bcea39c3
3
+ metadata.gz: 20dfc23f553782527d053042e02c2e58b2661c96
4
+ data.tar.gz: 22654fad486f48652f1a184ece70a3d54352b444
5
5
  SHA512:
6
- metadata.gz: 48e9fac9f32993daf3fa757908413deb595e66362934a91b93aa571313ceac211d4f3ff6be886e72629f6622fc3ff033a2af73be7b1afe3a00c18f76c9393f08
7
- data.tar.gz: eaf0dea201e969a9fc4079fb8584abe730c9f94222902dadf02b5210557150643ad44719eab9ed998bfdcda66f392152e24f64a8087e9c3f1512536212bc26d5
6
+ metadata.gz: cd85bf3cf5e6a8c31d6f152f1deaece79d3519164f0bb608f9b6deb24dc57e1c0a1351651c606c7dbdf0c9142ad64bf58092510ce2a654b2ebcd9b43ac9cbbdc
7
+ data.tar.gz: 90a968a7118048bb196507509a8e2e089e3ed668b8a23cb3353d0908a10f4596451708971d2f558347eb872eec947fc52e67169643026d0b773a3a45d5131c0d
@@ -1,7 +1,6 @@
1
1
  rvm:
2
2
  - 2.3.1
3
3
  - 2.2.5
4
- - 2.1.9
5
4
  - ruby-head
6
5
  gemfile:
7
6
  - gemfiles/Gemfile.rails-2.x
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2.0.0 - 2016/09/24
2
+
3
+ * Add support for Watir 6.0.
4
+
1
5
  ### 1.2.1 - 2016/06/15
2
6
 
3
7
  * Fix Browser#add_checker deprecation warning. PR #18 by Christophe Bliard.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://api.travis-ci.org/watir/watir-rails.png)](http://travis-ci.org/watir/watir-rails)
4
4
  [![Coverage](https://coveralls.io/repos/watir/watir-rails/badge.png?branch=master)](https://coveralls.io/r/watir/watir-rails)
5
5
 
6
- This gem makes the [Watir](https://github.com/watir/watir) work with Rails.
6
+ This gem makes [Watir](https://github.com/watir/watir) work with Rails.
7
7
 
8
8
 
9
9
  ## Installation
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
- require "bundler/gem_tasks"
2
1
  require "rspec/core/rake_task"
3
2
  RSpec::Core::RakeTask.new(:spec)
4
3
 
5
- task :default => :spec
6
- task :build => :spec
4
+ task default: :spec
5
+ task release: :spec
6
+ require "bundler/gem_tasks"
7
7
 
8
8
  require "yard"
9
9
  YARD::Rake::YardocTask.new
@@ -10,7 +10,7 @@ rescue LoadError
10
10
  require "initializer"
11
11
  end
12
12
 
13
- require File.expand_path("browser.rb", File.dirname(__FILE__))
13
+ require File.expand_path("rails/browser.rb", File.dirname(__FILE__))
14
14
  require File.expand_path("rails/middleware.rb", File.dirname(__FILE__))
15
15
 
16
16
  module Watir
@@ -33,8 +33,8 @@ module Watir
33
33
 
34
34
  Timeout.timeout(boot_timeout) { @server_thread.join(0.1) until running? }
35
35
  end
36
- rescue TimeoutError
37
- raise TimeoutError, "Rails Rack application timed out during boot"
36
+ rescue Timeout::Error
37
+ raise Timeout::Error, "Rails Rack application timed out during boot"
38
38
  end
39
39
 
40
40
  # Host for Rails app under test. Default is {.local_host}.
@@ -0,0 +1,45 @@
1
+ module Watir
2
+ # Reopened Watir::Browser class for working with Rails
3
+ class Browser
4
+ # @private
5
+ alias_method :_original_initialize, :initialize
6
+
7
+ # Will start Rails instance for Watir automatically and then invoke the
8
+ # original Watir::Browser#initialize method.
9
+ def initialize(*args)
10
+ Rails.boot
11
+ _original_initialize *args
12
+ add_exception_hook unless Rails.ignore_exceptions?
13
+ end
14
+
15
+ # @private
16
+ alias_method :_original_goto, :goto
17
+
18
+ # Opens the url with the browser instance.
19
+ # Will add {Rails.host} and {Rails.port} to the url when path is specified.
20
+ #
21
+ # @example Go to the regular url:
22
+ # browser.goto "http://google.com"
23
+ #
24
+ # @example Go to the controller path:
25
+ # browser.goto home_path
26
+ #
27
+ # @param [String] url URL to be navigated to.
28
+ def goto(url)
29
+ url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^(about|data|https?):}i
30
+ _original_goto url
31
+ end
32
+
33
+ private
34
+
35
+ def add_exception_hook
36
+ after_hooks.add do
37
+ if error = Rails.error
38
+ Rails.error = nil
39
+ raise error
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
@@ -1,5 +1,5 @@
1
1
  module Watir
2
2
  class Rails
3
- VERSION = "1.2.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -3,7 +3,9 @@
3
3
  module Watir
4
4
  class Browser
5
5
  def initialize(*args)
6
- require File.expand_path("fake_browser_with_goto", File.dirname(__FILE__))
6
+ end
7
+
8
+ def goto(url)
7
9
  end
8
10
  end
9
11
  end
@@ -6,22 +6,22 @@ describe Watir::Browser do
6
6
  context "#initialize" do
7
7
  it "starts Rails before opening the browser" do
8
8
  expect(Watir::Rails).to receive(:boot)
9
- expect_any_instance_of(Watir::Browser).to receive(:original_initialize).and_call_original
9
+ expect_any_instance_of(Watir::Browser).to receive(:_original_initialize).and_call_original
10
10
 
11
11
  Watir::Browser.new
12
12
  end
13
13
 
14
- it "does not add Exception checker when exceptions are ignored" do
14
+ it "does not add Exception hook when exceptions are ignored" do
15
15
  allow(Watir::Rails).to receive_messages(ignore_exceptions?: true, boot: nil)
16
16
 
17
- expect_any_instance_of(Watir::Browser).not_to receive(:add_exception_checker)
17
+ expect_any_instance_of(Watir::Browser).not_to receive(:add_exception_hook)
18
18
  Watir::Browser.new
19
19
  end
20
20
 
21
- it "adds Exception checker when exceptions are not ignored" do
21
+ it "adds Exception hook when exceptions are not ignored" do
22
22
  allow(Watir::Rails).to receive_messages(ignore_exceptions?: false, boot: nil)
23
23
 
24
- expect_any_instance_of(Watir::Browser).to receive(:add_exception_checker)
24
+ expect_any_instance_of(Watir::Browser).to receive(:add_exception_hook)
25
25
  Watir::Browser.new
26
26
  end
27
27
  end
@@ -34,32 +34,32 @@ describe Watir::Browser do
34
34
  let(:browser) { Watir::Browser.new }
35
35
 
36
36
  it "uses Rails for paths specified as an url" do
37
- expect(browser).to receive(:_new_goto).with("http://foo.com:42/foo/bar")
37
+ expect(browser).to receive(:_original_goto).with("http://foo.com:42/foo/bar")
38
38
  browser.goto("/foo/bar")
39
39
  end
40
40
 
41
41
  it "does not alter url with http:// scheme" do
42
- expect(browser).to receive(:_new_goto).with("http://baz.org/lol")
42
+ expect(browser).to receive(:_original_goto).with("http://baz.org/lol")
43
43
  browser.goto("http://baz.org/lol")
44
44
  end
45
45
 
46
46
  it "does not alter url with https:// scheme" do
47
- expect(browser).to receive(:_new_goto).with("https://baz.org/lol")
47
+ expect(browser).to receive(:_original_goto).with("https://baz.org/lol")
48
48
  browser.goto("https://baz.org/lol")
49
49
  end
50
50
 
51
51
  it "does not alter about:urls" do
52
- expect(browser).to receive(:_new_goto).with("about:url")
52
+ expect(browser).to receive(:_original_goto).with("about:url")
53
53
  browser.goto("about:url")
54
54
  end
55
55
 
56
56
  it "does not alter data:urls" do
57
- expect(browser).to receive(:_new_goto).with("data:url")
57
+ expect(browser).to receive(:_original_goto).with("data:url")
58
58
  browser.goto("data:url")
59
59
  end
60
60
 
61
61
  it "alters the unknown urls" do
62
- expect(browser).to receive(:_new_goto).with("http://foo.com:42/xxx:yyy")
62
+ expect(browser).to receive(:_original_goto).with("http://foo.com:42/xxx:yyy")
63
63
  browser.goto("http://foo.com:42/xxx:yyy")
64
64
  end
65
65
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_dependency "rack"
20
20
  gem.add_dependency "rails"
21
- gem.add_dependency "watir", "~> 5.0"
21
+ gem.add_dependency "watir", ">= 6.0.0.beta4"
22
22
 
23
23
  gem.add_development_dependency "yard"
24
24
  gem.add_development_dependency "redcarpet"
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: 1.2.1
4
+ version: 2.0.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: 2016-06-15 00:00:00.000000000 Z
11
+ date: 2016-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: watir
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: 6.0.0.beta4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: 6.0.0.beta4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -111,14 +111,13 @@ files:
111
111
  - Rakefile
112
112
  - gemfiles/Gemfile.rails-2.x
113
113
  - gemfiles/Gemfile.rails-3.x
114
- - lib/watir/browser.rb
115
114
  - lib/watir/rails.rb
115
+ - lib/watir/rails/browser.rb
116
116
  - lib/watir/rails/middleware.rb
117
117
  - lib/watir/version.rb
118
118
  - spec/spec_helper.rb
119
- - spec/support/fake_browser_with_goto.rb
120
119
  - spec/support/watir.rb
121
- - spec/watir/browser_spec.rb
120
+ - spec/watir/rails/browser_spec.rb
122
121
  - spec/watir/rails/middleware_spec.rb
123
122
  - spec/watir/rails_spec.rb
124
123
  - watir-rails.gemspec
@@ -142,15 +141,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
141
  version: '0'
143
142
  requirements: []
144
143
  rubyforge_project:
145
- rubygems_version: 2.4.4
144
+ rubygems_version: 2.6.4
146
145
  signing_key:
147
146
  specification_version: 4
148
147
  summary: Use Watir (http://github.com/watir/watir) in Rails.
149
148
  test_files:
150
149
  - spec/spec_helper.rb
151
- - spec/support/fake_browser_with_goto.rb
152
150
  - spec/support/watir.rb
153
- - spec/watir/browser_spec.rb
151
+ - spec/watir/rails/browser_spec.rb
154
152
  - spec/watir/rails/middleware_spec.rb
155
153
  - spec/watir/rails_spec.rb
156
154
  has_rdoc:
@@ -1,67 +0,0 @@
1
- module Watir
2
- # Reopened Watir::Browser class for working with Rails
3
- class Browser
4
- # @private
5
- alias_method :original_initialize, :initialize
6
-
7
- # Will start Rails instance for Watir automatically and then invoke the
8
- # original Watir::Browser#initialize method.
9
- def initialize(*args)
10
- initialize_rails_with_watir *args
11
- end
12
-
13
- # Opens the url with the browser instance.
14
- # Will add {Rails.host} and {Rails.port} to the url when path is specified.
15
- #
16
- # @example Go to the regular url:
17
- # browser.goto "http://google.com"
18
- #
19
- # @example Go to the controller path:
20
- # browser.goto home_path
21
- #
22
- # @param [String] url URL to be navigated to.
23
- def goto(url)
24
- url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^(about|data|https?):}i
25
- _new_goto url
26
- end
27
-
28
- private
29
-
30
- def override_and_preserve_original_methods(*method_names, &block)
31
- method_names.each do |method_name|
32
- next if respond_to? "_original_#{method_name}", true
33
- self.class.send :alias_method, "_original_#{method_name}", method_name
34
- end
35
-
36
- result = block.call
37
-
38
- method_names.each do |method_name|
39
- next if respond_to? "_new_#{method_name}", true
40
- self.class.send :alias_method, "_new_#{method_name}", method_name
41
-
42
- self.class.send :define_method, method_name do |*args|
43
- send("_original_#{method_name}", *args)
44
- #send("_new_#{method_name}", *args)
45
- end
46
- end
47
-
48
- result
49
- end
50
-
51
- def initialize_rails_with_watir(*args)
52
- Rails.boot
53
- override_and_preserve_original_methods(:goto) { original_initialize *args }
54
- add_exception_checker unless Rails.ignore_exceptions?
55
- end
56
-
57
- def add_exception_checker
58
- after_hooks.add do
59
- if error = Rails.error
60
- Rails.error = nil
61
- raise error
62
- end
63
- end
64
- end
65
- end
66
- end
67
-
@@ -1,8 +0,0 @@
1
- # Needed to simulate watir driver's gem (watir-webdriver or watir-classic).
2
-
3
- module Watir
4
- class Browser
5
- def goto(*args)
6
- end
7
- end
8
- end