watir-rspec 1.1.3 → 2.0.0

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
2
  SHA1:
3
- metadata.gz: 53a815c2800e2c39ece1da6f15c968e2721106d4
4
- data.tar.gz: 02d82629c228ec9fe0db971c8abe1eb64fbfa3fe
3
+ metadata.gz: b7e334fd2ce8294279e7c24f43373a308a135a37
4
+ data.tar.gz: 88728d14f335c70a8a6ebd3469064e83f893ae48
5
5
  SHA512:
6
- metadata.gz: 934b490d98fe0b59536cb5b3193e8de02524ab1eaaf6ecf0b78343f4f4af708e852587282100a628a5c430f678a80e664c7232bd7035389b51fcd5af3846868e
7
- data.tar.gz: cc000c8faa40fe8f79b47e7687c1db280840ee20777dc45017d88ea3f75c8e4ad15cb7654a5fe908a304e888171b9053f4c6c95f9ae1ea513dba4395b48861b8
6
+ metadata.gz: 5616334b3367d00836dffbfe0dd506ad0724754cdad5ee3b7e437d1600703543e8a28cce1f739fce6383b82b3fc99cf94f733bd32076afd711fc057166034cf6
7
+ data.tar.gz: 7f4563629337a557767228aff261f2fe0f2a92bf1270b022aed96091f48c741fb10ad2ef15ec1f3da9dd26411bfd82713220fcc5a604a1988af0174a369bf3e2
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2.0.0 - 2015/03/18
2
+
3
+ * Add support for RSpec 3.x. RSpec 2.x is not supported anymore (PR #10).
4
+
1
5
  ### 1.1.3 - 2015/03/11
2
6
 
3
7
  * Fix `Watir::RSpec.file_path` to not discard description (PR #11).
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2013 Jarmo Pertman
1
+ Copyright (c) Jarmo Pertman
2
2
 
3
3
  MIT License
4
4
 
@@ -88,6 +88,7 @@ RSpec.configure do |config|
88
88
  end
89
89
  ]
90
90
  end
91
+
91
92
  end
92
93
 
93
94
  def already_installed?
@@ -21,10 +21,19 @@ module Watir
21
21
  if browser.respond_to?(name)
22
22
  Helper.module_eval %Q[
23
23
  def #{name}(*args)
24
- browser.send(:#{name}, *args) {yield}
24
+ if block_given?
25
+ browser.send(:#{name}, *args) {yield}
26
+ else
27
+ browser.send(:#{name}, *args)
28
+ end
25
29
  end
26
30
  ]
27
- self.send(name, *args) {yield}
31
+
32
+ if block_given?
33
+ self.send(name, *args) {yield}
34
+ else
35
+ self.send(name, *args)
36
+ end
28
37
  else
29
38
  super
30
39
  end
@@ -1,3 +1,4 @@
1
+ require 'rspec/core/formatters'
1
2
  require 'rspec/core/formatters/html_formatter'
2
3
  require 'pathname'
3
4
  require 'fileutils'
@@ -9,6 +10,9 @@ module Watir
9
10
  # * saves html of the browser upon test failure
10
11
  # * saves all files generated/downloaded during the test and shows them in the report
11
12
  class HtmlFormatter < ::RSpec::Core::Formatters::HtmlFormatter
13
+
14
+ ::RSpec::Core::Formatters.register self, *(::RSpec::Core::Formatters::Loader.formatters[::RSpec::Core::Formatters::HtmlFormatter])
15
+
12
16
  # @private
13
17
  def initialize(output)
14
18
  @output_path = File.expand_path(ENV["WATIR_RESULTS_PATH"] || (output.respond_to?(:path) ? output.path : "tmp/spec-results/index.html"))
@@ -36,21 +40,6 @@ module Watir
36
40
  super
37
41
  end
38
42
 
39
- # @private
40
- def extra_failure_content(exception)
41
- browser = example_group.before_all_ivars[:@browser] || $browser
42
- return super unless browser && browser.exists?
43
-
44
- save_screenshot browser
45
- save_html browser
46
-
47
- content = []
48
- content << "<span>"
49
- @files_saved_during_example.each {|f| content << link_for(f)}
50
- content << "</span>"
51
- super + content.join($/)
52
- end
53
-
54
43
  # Generate unique file path for the current spec. If the file
55
44
  # will be created during that spec and spec fails then it will be
56
45
  # shown automatically in the html report.
@@ -68,6 +57,22 @@ module Watir
68
57
 
69
58
  private
70
59
 
60
+ # @private
61
+ def extra_failure_content(exception)
62
+ return super unless example_group # apparently there are cases where rspec failures are encountered and the example_group is not set (i.e. nil)
63
+ browser = example_group.before_context_ivars[:@browser] || $browser
64
+ return super unless browser && browser.exists?
65
+
66
+ save_screenshot browser
67
+ save_html browser
68
+
69
+ content = []
70
+ content << "<span>"
71
+ @files_saved_during_example.each {|f| content << link_for(f)}
72
+ content << "</span>"
73
+ super + content.join($/)
74
+ end
75
+
71
76
  def link_for(file)
72
77
  return unless File.exists?(file[:path])
73
78
 
@@ -10,17 +10,17 @@ module Watir
10
10
  # result should be true for the whole specified time period.
11
11
  #
12
12
  # @example Wait for 2 seconds until element is present (element exists and is visible)
13
- # text_field.should be_present.within(2)
13
+ # expect(text_field).to be_present.within(2)
14
14
  #
15
15
  # @example Wait for 2 seconds until element is visible
16
- # text_field.should be_visible.within(2)
16
+ # expect(text_field).to be_visible.within(2)
17
17
  #
18
18
  # @example Wait for 2 seconds until element exists
19
- # text_field.should exist.within(2)
19
+ # expect(text_field).to exist.within(2)
20
20
  #
21
21
  # @example Make sure that container is visible for the whole time during 2 seconds
22
22
  # button.click
23
- # div.should be_visible.during(2)
23
+ # expect(text_field).to be_visible.during(2)
24
24
  module Matchers
25
25
  def be_present
26
26
  BaseMatcher.new :present?
@@ -1,5 +1,5 @@
1
- module Watir
2
- class RSpec
3
- VERSION = "1.1.3"
4
- end
5
- end
1
+ module Watir
2
+ class RSpec
3
+ VERSION = "2.0.0"
4
+ end
5
+ end
@@ -8,19 +8,19 @@ describe TestModel do
8
8
  before { described_class.class_variable_set :@@shared_connection, nil }
9
9
 
10
10
  it "reuses the connection" do
11
- described_class.should_receive(:retrieve_connection).once.and_return(:established_connection)
11
+ expect(described_class).to receive(:retrieve_connection).once.and_return(:established_connection)
12
12
 
13
- 2.times { described_class.connection.should == :established_connection }
13
+ 2.times { expect(described_class.connection).to be_eql :established_connection }
14
14
  end
15
15
 
16
16
  it "uses mutex" do
17
- described_class.should_receive(:retrieve_connection).once { sleep 0.1; :established_connection }
17
+ expect(described_class).to receive(:retrieve_connection).once { sleep 0.1; :established_connection }
18
18
 
19
19
  thr = Thread.new { described_class.connection }
20
20
 
21
21
  t = Time.now
22
22
  described_class.connection
23
- (Time.now - t).should be >= 0.1
23
+ expect(Time.now - t).to be >= 0.1
24
24
  thr.join
25
25
  end
26
26
  end
@@ -7,50 +7,50 @@ describe Watir::RSpec::Helper do
7
7
  context "#browser" do
8
8
  it "delegates to @browser if exists" do
9
9
  @browser = :browser
10
- browser.should == @browser
10
+ expect(browser).to be @browser
11
11
  end
12
12
 
13
13
  it "delegates to @browser if @browser exists even if $browser exists" do
14
14
  @browser = :browser
15
15
  $browser = :global_browser
16
- browser.should == @browser
16
+ expect(browser).to be @browser
17
17
  end
18
18
 
19
19
  it "delegates to $browser if @browser does not exist" do
20
20
  $browser = :global_browser
21
- browser.should == $browser
21
+ expect(browser).to be $browser
22
22
  end
23
23
  end
24
24
 
25
25
  context "#method_missing" do
26
26
  it "redirects missing methods to browser if method exists" do
27
27
  @browser = double("browser", coolness_factor: :very)
28
- coolness_factor.should == :very
28
+ expect(coolness_factor).to eql :very
29
29
  end
30
30
 
31
31
  it "raises error when browser does not have method" do
32
32
  @browser = double("browser")
33
- described_class.should_not be_method_defined :not_existing_method
33
+ expect(described_class).not_to be_method_defined :not_existing_method
34
34
 
35
35
  expect do
36
36
  self.not_existing_method
37
37
  end.to raise_error(NoMethodError)
38
-
39
- described_class.should_not be_method_defined :not_existing_method
38
+ expect(described_class).not_to be_method_defined :not_existing_method
40
39
  end
41
40
 
42
41
  it "adds browser methods to the helper" do
43
42
  @browser = double("browser", method_to_be_defined: :done)
44
- described_class.should_not be_method_defined :method_to_be_defined
45
- method_to_be_defined.should == :done
46
- described_class.should be_method_defined :method_to_be_defined
43
+
44
+ expect(described_class).not_to be_method_defined :method_to_be_defined
45
+ expect(method_to_be_defined).to eql :done
46
+ expect(described_class).to be_method_defined :method_to_be_defined
47
47
  end
48
48
  end
49
49
 
50
50
  it "#p is delegated to the browser" do
51
51
  @browser = double("browser", p: "#p")
52
- described_class.should_not_receive(:method_missing)
52
+ expect(described_class).not_to receive(:method_missing)
53
53
 
54
- p.should == "#p"
54
+ expect(p).to eql "#p"
55
55
  end
56
56
  end
@@ -5,25 +5,25 @@ describe Watir::RSpec::Matchers::BaseMatcher do
5
5
 
6
6
  it "#matches?" do
7
7
  object = double("element", foo?: true)
8
- object.should be_foo
8
+ expect(object).to be_foo
9
9
  end
10
10
 
11
11
  it "#matches? with error" do
12
12
  object = double("element", foo?: false)
13
13
  expect {
14
- object.should be_foo
14
+ expect(object).to be_foo
15
15
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
16
16
  end
17
17
 
18
18
  it "#does_not_match?" do
19
19
  object = double("element", foo?: false)
20
- object.should_not be_foo
20
+ expect(object).not_to be_foo
21
21
  end
22
22
 
23
23
  it "#does_not_match? with error" do
24
24
  object = double("element", foo?: true)
25
25
  expect {
26
- object.should_not be_foo
26
+ expect(object).not_to be_foo
27
27
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
28
28
  end
29
29
 
@@ -33,10 +33,10 @@ describe Watir::RSpec::Matchers::BaseMatcher do
33
33
  it "#matches?" do
34
34
  object = double("element")
35
35
  @result = false
36
- object.stub(:foo?) { @result }
36
+ allow(object).to receive (:foo?) { @result }
37
37
  thr = Thread.new { sleep 0.1; @result = true }
38
38
 
39
- object.should be_foo.within(1)
39
+ expect(object).to be_foo.within(1)
40
40
  thr.join
41
41
  end
42
42
 
@@ -44,14 +44,14 @@ describe Watir::RSpec::Matchers::BaseMatcher do
44
44
  object = double("element", foo?: false)
45
45
 
46
46
  expect {
47
- object.should be_foo.within(0.1)
47
+ expect(object).to be_foo.within(0.1)
48
48
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
49
49
  end
50
50
 
51
51
  it "#matches? with some other error" do
52
52
  object = double("element")
53
53
  raised = false
54
- object.stub(:foo?) do
54
+ allow(object).to receive (:foo?) do
55
55
  unless raised
56
56
  raised = true
57
57
  raise "Some unexpected exception"
@@ -61,17 +61,17 @@ describe Watir::RSpec::Matchers::BaseMatcher do
61
61
  end
62
62
  end
63
63
 
64
- object.should be_foo.within(1)
65
- raised.should be_true
64
+ expect(object).to be_foo.within(1)
65
+ expect(raised).to be true
66
66
  end
67
67
 
68
68
  it "#does_not_match?" do
69
69
  object = double("element")
70
70
  @result = true
71
- object.stub(:foo?) { @result }
71
+ allow(object).to receive (:foo?) { @result }
72
72
  thr = Thread.new { sleep 0.1; @result = false }
73
73
 
74
- object.should_not be_foo.within(1)
74
+ expect(object).not_to be_foo.within(1)
75
75
  thr.join
76
76
  end
77
77
 
@@ -79,14 +79,14 @@ describe Watir::RSpec::Matchers::BaseMatcher do
79
79
  object = double("element", foo?: true)
80
80
 
81
81
  expect {
82
- object.should_not be_foo.within(0.1)
82
+ expect(object).not_to be_foo.within(0.1)
83
83
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
84
84
  end
85
85
 
86
86
  it "#does_not_match? with some other error" do
87
87
  object = double("element")
88
88
  raised = false
89
- object.stub(:foo?) do
89
+ allow(object).to receive (:foo?) do
90
90
  unless raised
91
91
  raised = true
92
92
  raise "Some unexpected exception"
@@ -96,8 +96,8 @@ describe Watir::RSpec::Matchers::BaseMatcher do
96
96
  end
97
97
  end
98
98
 
99
- object.should_not be_foo.within(1)
100
- raised.should be_true
99
+ expect(object).not_to be_foo.within(1)
100
+ expect(raised).to be true
101
101
  end
102
102
  end
103
103
 
@@ -107,17 +107,17 @@ describe Watir::RSpec::Matchers::BaseMatcher do
107
107
  it "#matches?" do
108
108
  object = double("element", foo?: true)
109
109
 
110
- object.should be_foo.during(0.1)
110
+ expect(object).to be_foo.during(0.1)
111
111
  end
112
112
 
113
113
  it "#matches? with timeout error" do
114
114
  object = double("element")
115
115
  @result = true
116
- object.stub(:foo?) { @result }
116
+ allow(object).to receive (:foo?) { @result }
117
117
  thr = Thread.new { sleep 0.1; @result = false }
118
118
 
119
119
  expect {
120
- object.should be_foo.during(1)
120
+ expect(object).to be_foo.during(1)
121
121
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
122
122
  thr.join
123
123
  end
@@ -125,7 +125,7 @@ describe Watir::RSpec::Matchers::BaseMatcher do
125
125
  it "#matches? with some other error" do
126
126
  object = double("element")
127
127
  raised = false
128
- object.stub(:foo?) do
128
+ allow(object).to receive (:foo?) do
129
129
  unless raised
130
130
  raised = true
131
131
  raise "Some unexpected exception"
@@ -134,24 +134,24 @@ describe Watir::RSpec::Matchers::BaseMatcher do
134
134
  end
135
135
  end
136
136
 
137
- object.should be_foo.during(0.1)
138
- raised.should be_true
137
+ expect(object).to be_foo.during(0.1)
138
+ expect(raised).to be true
139
139
  end
140
140
 
141
141
  it "#does_not_match?" do
142
142
  object = double("element", foo?: false)
143
143
 
144
- object.should_not be_foo.during(0.1)
144
+ expect(object).not_to be_foo.during(0.1)
145
145
  end
146
146
 
147
147
  it "#does_not_match? with timeout error" do
148
148
  object = double("element")
149
149
  @result = false
150
- object.stub(:foo?) { @result }
150
+ allow(object).to receive (:foo?) { @result }
151
151
  thr = Thread.new { sleep 0.1; @result = true }
152
152
 
153
153
  expect {
154
- object.should_not be_foo.during(1)
154
+ expect(object).not_to be_foo.during(1)
155
155
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
156
156
  thr.join
157
157
  end
@@ -159,7 +159,7 @@ describe Watir::RSpec::Matchers::BaseMatcher do
159
159
  it "#does_not_match? with some other error" do
160
160
  object = double("element")
161
161
  raised = false
162
- object.stub(:foo?) do
162
+ allow(object).to receive (:foo?) do
163
163
  unless raised
164
164
  raised = true
165
165
  raise "Some unexpected exception"
@@ -168,14 +168,14 @@ describe Watir::RSpec::Matchers::BaseMatcher do
168
168
  end
169
169
  end
170
170
 
171
- object.should_not be_foo.during(0.1)
172
- raised.should be_true
171
+ expect(object).not_to be_foo.during(0.1)
172
+ expect(raised).to be true
173
173
  end
174
174
  end
175
175
 
176
176
  def should_take_at_least(seconds)
177
177
  t = Time.now
178
178
  yield
179
- (Time.now - t).should be >= seconds
179
+ expect(Time.now - t).to be >= seconds
180
180
  end
181
181
  end
@@ -5,19 +5,19 @@ describe Watir::RSpec::Matchers do
5
5
 
6
6
  it "#be_present" do
7
7
  matcher = be_present
8
- matcher.should == Watir::RSpec::Matchers::BaseMatcher
9
- matcher.instance_variable_get(:@predicate).should == :present?
8
+ expect(matcher).to be_a Watir::RSpec::Matchers::BaseMatcher
9
+ expect(matcher.instance_variable_get(:@predicate)).to eql :present?
10
10
  end
11
11
 
12
12
  it "#be_visible" do
13
13
  matcher = be_visible
14
- matcher.should == Watir::RSpec::Matchers::BaseMatcher
15
- matcher.instance_variable_get(:@predicate).should == :visible?
14
+ expect(matcher).to be_a Watir::RSpec::Matchers::BaseMatcher
15
+ expect(matcher.instance_variable_get(:@predicate)).to eql :visible?
16
16
  end
17
17
 
18
18
  it "#exist" do
19
19
  matcher = exist
20
- matcher.should == Watir::RSpec::Matchers::BaseMatcher
21
- matcher.instance_variable_get(:@predicate).should == :exist?
20
+ expect(matcher).to be_a Watir::RSpec::Matchers::BaseMatcher
21
+ expect(matcher.instance_variable_get(:@predicate)).to eql :exist?
22
22
  end
23
23
  end
@@ -4,18 +4,18 @@ describe Watir::RSpec do
4
4
  context "#file_path" do
5
5
  it "without description" do
6
6
  formatter = double("formatter", file_path: "file-path")
7
- Watir::RSpec.stub(formatter: formatter)
8
- formatter.should_receive(:file_path).with("name", nil)
7
+ allow(Watir::RSpec).to receive (:formatter) {formatter}
8
+ expect(formatter).to receive(:file_path).with("name", nil)
9
9
 
10
- Watir::RSpec.file_path("name").should == "file-path"
10
+ expect(Watir::RSpec.file_path("name")).to be == "file-path"
11
11
  end
12
12
 
13
13
  it "with description" do
14
14
  formatter = double("formatter", file_path: "file-path")
15
- Watir::RSpec.stub(formatter: formatter)
16
- formatter.should_receive(:file_path).with("name", "description")
15
+ allow(Watir::RSpec).to receive (:formatter) {formatter}
16
+ expect(formatter).to receive(:file_path).with("name", "description")
17
17
 
18
- Watir::RSpec.file_path("name", "description").should == "file-path"
18
+ expect(Watir::RSpec.file_path("name", "description")).to be == "file-path"
19
19
  end
20
20
  end
21
21
  end
data/watir-rspec.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Watir::RSpec::VERSION
17
17
 
18
- gem.add_dependency "rspec", "~>2.0"
18
+ gem.add_dependency "rspec", "~>3.0"
19
19
  gem.add_dependency "watir", "~>5.0"
20
20
 
21
21
  gem.add_development_dependency "yard"
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: 1.1.3
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: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: watir
29
29
  requirement: !ruby/object:Gem::Requirement