watir-rspec 2.0.1 → 2.0.2
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/CHANGES.md +4 -0
- data/bin/watir-rspec +0 -0
- data/lib/watir/rspec/helper.rb +49 -48
- data/lib/watir/rspec/version.rb +1 -1
- data/spec/watir/rspec/helper_spec.rb +74 -56
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe29b37229f959db5b8b6b466d9e4fb7d88b5c8
|
4
|
+
data.tar.gz: 6a9a31c3b8df8a13e6754f5f0613f1f001911af5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70f3fe05b402535b0a8d320af933537d785b2b625ebff64150d71f6afb2c0b09dd22d5e0fbf788a95b79032dd9291cab6e63dd2a39b8ddba2765fc43e26b9687
|
7
|
+
data.tar.gz: 55cd37ecf601751480795f34671511679a54d6bef57aa90f5f2f0bcaef54e928e4afb283906380992c90f7394278a5e7e0d518df6023e93ca5188b1b992b2942
|
data/CHANGES.md
CHANGED
data/bin/watir-rspec
CHANGED
File without changes
|
data/lib/watir/rspec/helper.rb
CHANGED
@@ -1,48 +1,49 @@
|
|
1
|
-
require "forwardable"
|
2
|
-
|
3
|
-
module Watir
|
4
|
-
class RSpec
|
5
|
-
module Helper
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
# @return [Watir::Browser] a current browser instance if it is initialized with
|
9
|
-
# @browser or $browser variable name.
|
10
|
-
def browser
|
11
|
-
@browser || $browser
|
12
|
-
end
|
13
|
-
|
14
|
-
# Will dispatch all missing methods to the {#browser} instance.
|
15
|
-
# @example Makes it possible to use Watir::Browser methods without specifying the browser instance in the specs like this:
|
16
|
-
# it "should do something" do
|
17
|
-
# # notice that we're calling Watir::Browser#text_field here directly
|
18
|
-
# text_field(:id => "foo").should be_present
|
19
|
-
# end
|
20
|
-
def method_missing(name, *args)
|
21
|
-
if browser.respond_to?(name)
|
22
|
-
Helper.module_eval %Q[
|
23
|
-
def #{name}(*args)
|
24
|
-
if block_given?
|
25
|
-
browser.send(:#{name}, *args)
|
26
|
-
else
|
27
|
-
browser.send(:#{name}, *args)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
]
|
31
|
-
|
32
|
-
if block_given?
|
33
|
-
self.send(name, *args)
|
34
|
-
else
|
35
|
-
self.send(name, *args)
|
36
|
-
end
|
37
|
-
else
|
38
|
-
super
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
1
|
+
require "forwardable"
|
2
|
+
|
3
|
+
module Watir
|
4
|
+
class RSpec
|
5
|
+
module Helper
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
# @return [Watir::Browser] a current browser instance if it is initialized with
|
9
|
+
# @browser or $browser variable name.
|
10
|
+
def browser
|
11
|
+
@browser || $browser
|
12
|
+
end
|
13
|
+
|
14
|
+
# Will dispatch all missing methods to the {#browser} instance.
|
15
|
+
# @example Makes it possible to use Watir::Browser methods without specifying the browser instance in the specs like this:
|
16
|
+
# it "should do something" do
|
17
|
+
# # notice that we're calling Watir::Browser#text_field here directly
|
18
|
+
# text_field(:id => "foo").should be_present
|
19
|
+
# end
|
20
|
+
def method_missing(name, *args)
|
21
|
+
if browser.respond_to?(name)
|
22
|
+
Helper.module_eval %Q[
|
23
|
+
def #{name}(*args)
|
24
|
+
if block_given?
|
25
|
+
browser.send(:#{name}, *args, &Proc.new)
|
26
|
+
else
|
27
|
+
browser.send(:#{name}, *args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
]
|
31
|
+
|
32
|
+
if block_given?
|
33
|
+
self.send(name, *args, &Proc.new)
|
34
|
+
else
|
35
|
+
self.send(name, *args)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# make sure that using method 'p' will be invoked on browser
|
44
|
+
# and not Kernel
|
45
|
+
# use Kernel.p if you need to dump some variable
|
46
|
+
def_delegators :browser, :p
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/watir/rspec/version.rb
CHANGED
@@ -1,56 +1,74 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Watir::RSpec::Helper do
|
4
|
-
before { self.send :extend, described_class }
|
5
|
-
after { $browser = @browser = nil }
|
6
|
-
|
7
|
-
context "#browser" do
|
8
|
-
it "delegates to @browser if exists" do
|
9
|
-
@browser = :browser
|
10
|
-
expect(browser).to be @browser
|
11
|
-
end
|
12
|
-
|
13
|
-
it "delegates to @browser if @browser exists even if $browser exists" do
|
14
|
-
@browser = :browser
|
15
|
-
$browser = :global_browser
|
16
|
-
expect(browser).to be @browser
|
17
|
-
end
|
18
|
-
|
19
|
-
it "delegates to $browser if @browser does not exist" do
|
20
|
-
$browser = :global_browser
|
21
|
-
expect(browser).to be $browser
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
expect(
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Watir::RSpec::Helper do
|
4
|
+
before { self.send :extend, described_class }
|
5
|
+
after { $browser = @browser = nil }
|
6
|
+
|
7
|
+
context "#browser" do
|
8
|
+
it "delegates to @browser if exists" do
|
9
|
+
@browser = :browser
|
10
|
+
expect(browser).to be @browser
|
11
|
+
end
|
12
|
+
|
13
|
+
it "delegates to @browser if @browser exists even if $browser exists" do
|
14
|
+
@browser = :browser
|
15
|
+
$browser = :global_browser
|
16
|
+
expect(browser).to be @browser
|
17
|
+
end
|
18
|
+
|
19
|
+
it "delegates to $browser if @browser does not exist" do
|
20
|
+
$browser = :global_browser
|
21
|
+
expect(browser).to be $browser
|
22
|
+
end
|
23
|
+
|
24
|
+
context "methods with block" do
|
25
|
+
before { @browser = double("browser") }
|
26
|
+
|
27
|
+
it "are delegated to browser" do
|
28
|
+
expect(@browser).to receive(:window).with(title: "my_window") { |&block| block.call }
|
29
|
+
|
30
|
+
block_parameter = lambda { "my block content" }
|
31
|
+
expect(window(title: "my_window", &block_parameter)).to be == "my block content"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "having parameters are properly delegated to browser" do
|
35
|
+
expect(@browser).to receive(:window).with(:title => "my_window").and_yield("first", "second")
|
36
|
+
|
37
|
+
block_parameter = lambda { |parameter_1, parameter_2| [parameter_1, parameter_2] }
|
38
|
+
expect(window(title: "my_window", &block_parameter)).to be == ["first", "second"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "#method_missing" do
|
44
|
+
it "redirects missing methods to browser if method exists" do
|
45
|
+
@browser = double("browser", coolness_factor: :very)
|
46
|
+
expect(coolness_factor).to eql :very
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises error when browser does not have method" do
|
50
|
+
@browser = double("browser")
|
51
|
+
expect(described_class).not_to be_method_defined :not_existing_method
|
52
|
+
|
53
|
+
expect do
|
54
|
+
self.not_existing_method
|
55
|
+
end.to raise_error(NoMethodError)
|
56
|
+
expect(described_class).not_to be_method_defined :not_existing_method
|
57
|
+
end
|
58
|
+
|
59
|
+
it "adds browser methods to the helper" do
|
60
|
+
@browser = double("browser", method_to_be_defined: :done)
|
61
|
+
|
62
|
+
expect(described_class).not_to be_method_defined :method_to_be_defined
|
63
|
+
expect(method_to_be_defined).to eql :done
|
64
|
+
expect(described_class).to be_method_defined :method_to_be_defined
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "#p is delegated to the browser" do
|
69
|
+
@browser = double("browser", p: "#p")
|
70
|
+
expect(described_class).not_to receive(:method_missing)
|
71
|
+
|
72
|
+
expect(p).to eql "#p"
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarmo Pertman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.6
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Use Watir with RSpec with ease.
|