watirspec 0.1.1 → 0.1.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.
- data/History.rdoc +8 -0
- data/lib/watirspec/spec.rb +43 -0
- data/lib/watirspec/version.rb +1 -1
- data/lib/watirspec/watir.rb +6 -7
- data/lib/watirspec.rb +1 -1
- data/spec/spec_match_array_spec.rb +21 -0
- data/spec/watir_table_row_spec.rb +6 -0
- data/spec/watir_table_spec.rb +8 -0
- data/templates/common/environment.rb +2 -2
- data/watirspec-0.1.1.gem +0 -0
- metadata +6 -4
- data/lib/watirspec/rspec.rb +0 -17
data/History.rdoc
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== Version 0.1.2 / 2010-04-05
|
2
|
+
|
3
|
+
* Added match_array matcher for RSpec for using with Array when regular expressions are needed. It is useful when verifying html tables with #to_a method.
|
4
|
+
expected_array = ["1", "2", /\d+/, "3"]
|
5
|
+
|
6
|
+
["1", "2", "66", "3"].should match_array(expected_array)
|
7
|
+
table(:id => "table_id").to_a.should match_array(expected_array)
|
8
|
+
|
1
9
|
=== Version 0.1.1 / 2010-04-04
|
2
10
|
|
3
11
|
* Watir::Table#to_a and Watir::TableRow#to_a work now well with tr, th, td elements, colspan and nested tables.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Spec::Runner.configure do |config| #:nodoc:
|
2
|
+
config.include(WatiRspec::SpecHelper)
|
3
|
+
|
4
|
+
config.before(:all) do
|
5
|
+
open_browser_at "about:blank"
|
6
|
+
end
|
7
|
+
|
8
|
+
config.after(:all) do
|
9
|
+
close
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Spec #:nodoc:all
|
14
|
+
class ExampleGroup
|
15
|
+
subject {self}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# match_array is useful for matching arrays where some elements are regular expressions.
|
20
|
+
# expected_array = ["1", "2", /\d+/, "3"]
|
21
|
+
#
|
22
|
+
# ["1", "2", "66", "3"].should match_array(expected_array)
|
23
|
+
# table(:id => "table_id").to_a.should match_array(expected_array)
|
24
|
+
Spec::Matchers.define :match_array do |array2|
|
25
|
+
match do |array1|
|
26
|
+
raise "match_array works only with Array objects!" unless array1.is_a?(Array) && array2.is_a?(Array)
|
27
|
+
match?(array1, array2)
|
28
|
+
end
|
29
|
+
|
30
|
+
def match?(array1, array2)
|
31
|
+
array2.each_with_index do |element, i|
|
32
|
+
if element.is_a?(Array)
|
33
|
+
return false unless match?(array1[i], element)
|
34
|
+
elsif element.is_a?(Regexp)
|
35
|
+
return false unless array1[i] =~ element
|
36
|
+
else
|
37
|
+
return false unless array1[i] == element
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
true
|
42
|
+
end
|
43
|
+
end
|
data/lib/watirspec/version.rb
CHANGED
data/lib/watirspec/watir.rb
CHANGED
@@ -86,11 +86,7 @@ module Watir
|
|
86
86
|
def to_a
|
87
87
|
assert_exists
|
88
88
|
y = []
|
89
|
-
@o.
|
90
|
-
# make sure that this row is directly child element of the table
|
91
|
-
# and not from some inner table
|
92
|
-
next unless row.parentElement.parentElement.uniqueID == @o.uniqueID
|
93
|
-
|
89
|
+
@o.rows.each do |row|
|
94
90
|
y << TableRow.new(@container, :ole_object, row).to_a
|
95
91
|
end
|
96
92
|
y
|
@@ -99,7 +95,7 @@ module Watir
|
|
99
95
|
|
100
96
|
class TableRow < Element
|
101
97
|
|
102
|
-
# This method returns (multi
|
98
|
+
# This method returns (multi-dimensional) array of the text's in table's row.
|
103
99
|
#
|
104
100
|
# It works with th, td elements, colspan, rowspan and nested tables.
|
105
101
|
def to_a
|
@@ -108,7 +104,10 @@ module Watir
|
|
108
104
|
@o.cells.each do |cell|
|
109
105
|
inner_tables = cell.getElementsByTagName("TABLE")
|
110
106
|
inner_tables.each do |inner_table|
|
111
|
-
|
107
|
+
# make sure that the inner table is directly child for this cell
|
108
|
+
if inner_table.parentElement.uniqueID == cell.uniqueID
|
109
|
+
y << Table.new(@container, :ole_object, inner_table).to_a
|
110
|
+
end
|
112
111
|
end
|
113
112
|
|
114
113
|
if inner_tables.length == 0
|
data/lib/watirspec.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec/autorun"
|
2
|
+
require "watirspec"
|
3
|
+
|
4
|
+
describe "Array match_array matcher" do
|
5
|
+
|
6
|
+
it "matches other arrays with regexps" do
|
7
|
+
expected_ary = ["1", "2", "3", /\d/]
|
8
|
+
["1", "2", "3", "5"].should match_array(expected_ary)
|
9
|
+
|
10
|
+
expected_ary = ["1", ["2", /\d+/], /3/]
|
11
|
+
["1", [], "4"].should_not match_array(expected_ary)
|
12
|
+
["1", ["2", "55"], "3"].should match_array(expected_ary)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't work with other objects than Array" do
|
16
|
+
lambda {"".should match_array("")}.should raise_exception
|
17
|
+
lambda {[].should match_array("")}.should raise_exception
|
18
|
+
lambda {"".should match_array([])}.should raise_exception
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -23,6 +23,12 @@ describe Watir::TableRow do
|
|
23
23
|
second_row.to_a.should =~ [[%w[11 12], %w[13 14]], "3"]
|
24
24
|
end
|
25
25
|
|
26
|
+
it "#to_a works with deep-nested tables" do
|
27
|
+
second_row = table(:id => "deepnested")[2]
|
28
|
+
second_row.to_a.should =~ [[%w[11 12],
|
29
|
+
[[["404", "405"], ["406", "407"]], "14"]], "3"]
|
30
|
+
end
|
31
|
+
|
26
32
|
it "#to_a works with colspan" do
|
27
33
|
second_row = table(:id => "colspan")[2]
|
28
34
|
second_row.to_a.should == ["3"]
|
data/spec/watir_table_spec.rb
CHANGED
@@ -34,6 +34,14 @@ describe Watir::Table do
|
|
34
34
|
table(:id => "nested").to_a.should =~ expected_table
|
35
35
|
end
|
36
36
|
|
37
|
+
it "#to_a works with deep-nested tables" do
|
38
|
+
expected_table = [
|
39
|
+
%w[1 2],
|
40
|
+
[[%w[11 12], [[["404", "405"], ["406", "407"]], "14"]], "3"]
|
41
|
+
]
|
42
|
+
table(:id => "deepnested").to_a.should =~ expected_table
|
43
|
+
end
|
44
|
+
|
37
45
|
it "#to_a works with colspan" do
|
38
46
|
expected_table = [
|
39
47
|
%w[1 2],
|
@@ -1,7 +1,7 @@
|
|
1
1
|
=begin
|
2
|
-
you have to
|
2
|
+
you have to load this file from your projects' environment.rb, which
|
3
3
|
will use common functionality:
|
4
|
-
|
4
|
+
WatiRspec::Util.load_common
|
5
5
|
|
6
6
|
add all your require statements into this file to avoid unnecessary
|
7
7
|
code in your other projects' files
|
data/watirspec-0.1.1.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jarmo Pertman
|
@@ -122,8 +122,8 @@ files:
|
|
122
122
|
- lib/spec.opts
|
123
123
|
- lib/watirspec/autoit.rb
|
124
124
|
- lib/watirspec/html_formatter.rb
|
125
|
-
- lib/watirspec/rspec.rb
|
126
125
|
- lib/watirspec/runner.rb
|
126
|
+
- lib/watirspec/spec.rb
|
127
127
|
- lib/watirspec/spec_helper.rb
|
128
128
|
- lib/watirspec/util.rb
|
129
129
|
- lib/watirspec/version.rb
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- Rakefile
|
135
135
|
- README.rdoc
|
136
136
|
- spec/spec_helper_spec.rb
|
137
|
+
- spec/spec_match_array_spec.rb
|
137
138
|
- spec/util_spec.rb
|
138
139
|
- spec/watir_table_row_spec.rb
|
139
140
|
- spec/watir_table_spec.rb
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- templates/project/ide_runner.rb
|
147
148
|
- templates/project/spec/dummy_spec.rb
|
148
149
|
- watirspec-0.1.1.gem
|
150
|
+
- watirspec-0.1.2.gem
|
149
151
|
has_rdoc: true
|
150
152
|
homepage: http://github.com/jarmo/WatiRspec
|
151
153
|
licenses: []
|
@@ -187,6 +189,6 @@ rubyforge_project:
|
|
187
189
|
rubygems_version: 1.3.6
|
188
190
|
signing_key:
|
189
191
|
specification_version: 3
|
190
|
-
summary: watirspec 0.1.
|
192
|
+
summary: watirspec 0.1.2
|
191
193
|
test_files: []
|
192
194
|
|
data/lib/watirspec/rspec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
Spec::Runner.configure do |config| #:nodoc:
|
2
|
-
config.include(WatiRspec::SpecHelper)
|
3
|
-
|
4
|
-
config.before(:all) do
|
5
|
-
open_browser_at "about:blank"
|
6
|
-
end
|
7
|
-
|
8
|
-
config.after(:all) do
|
9
|
-
close
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module Spec #:nodoc:all
|
14
|
-
class ExampleGroup
|
15
|
-
subject {self}
|
16
|
-
end
|
17
|
-
end
|