celerity 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -1
- data/Manifest.txt +174 -0
- data/README.txt +19 -10
- data/config/hoe.rb +68 -0
- data/config/requirements.rb +15 -0
- data/lib/celerity.rb +14 -11
- data/lib/celerity/collections.rb +37 -8
- data/lib/celerity/container.rb +100 -3
- data/lib/celerity/disabled_element.rb +4 -2
- data/lib/celerity/element.rb +21 -8
- data/lib/celerity/element_collections.rb +4 -7
- data/lib/celerity/element_locator.rb +1 -0
- data/lib/celerity/elements/button.rb +6 -2
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +1 -2
- data/lib/celerity/elements/frame.rb +0 -3
- data/lib/celerity/elements/image.rb +1 -4
- data/lib/celerity/elements/label.rb +1 -0
- data/lib/celerity/elements/link.rb +2 -0
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +3 -5
- data/lib/celerity/elements/select_list.rb +3 -10
- data/lib/celerity/elements/table.rb +8 -22
- data/lib/celerity/elements/table_body.rb +5 -11
- data/lib/celerity/elements/table_cell.rb +1 -0
- data/lib/celerity/elements/table_footer.rb +30 -0
- data/lib/celerity/elements/table_header.rb +30 -0
- data/lib/celerity/elements/table_row.rb +5 -3
- data/lib/celerity/elements/text_field.rb +18 -13
- data/lib/celerity/exception.rb +8 -8
- data/lib/celerity/extra/method_generator.rb +5 -2
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/ie.rb +195 -141
- data/lib/celerity/non_control_elements.rb +30 -4
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +62 -0
- data/setup.rb +0 -2
- data/spec/area_spec.rb +4 -1
- data/spec/areas_spec.rb +1 -1
- data/spec/button_spec.rb +35 -17
- data/spec/buttons_spec.rb +1 -1
- data/spec/checkbox_spec.rb +6 -4
- data/spec/checkboxes_spec.rb +1 -1
- data/spec/div_spec.rb +20 -19
- data/spec/divs_spec.rb +2 -2
- data/spec/element_spec.rb +13 -2
- data/spec/filefield_spec.rb +6 -3
- data/spec/filefields_spec.rb +1 -1
- data/spec/form_spec.rb +4 -1
- data/spec/forms_spec.rb +1 -1
- data/spec/frame_spec.rb +6 -2
- data/spec/hidden_spec.rb +8 -4
- data/spec/hiddens_spec.rb +1 -1
- data/spec/hn_spec.rb +86 -0
- data/spec/hns_spec.rb +41 -0
- data/spec/html/bug_duplicate_attributes.html +14 -0
- data/spec/html/bug_javascript_001.html +11 -0
- data/spec/html/forms_with_input_elements.html +11 -11
- data/spec/html/images.html +18 -15
- data/spec/html/latin1_text.html +16 -0
- data/spec/html/non_control_elements.html +28 -4
- data/spec/html/tables.html +3 -3
- data/spec/html/utf8_text.html +15 -0
- data/spec/htmlunit_spec.rb +27 -0
- data/spec/ie_spec.rb +47 -12
- data/spec/image_spec.rb +4 -7
- data/spec/images_spec.rb +3 -2
- data/spec/label_spec.rb +4 -3
- data/spec/labels_spec.rb +1 -1
- data/spec/li_spec.rb +11 -8
- data/spec/link_spec.rb +5 -1
- data/spec/links_spec.rb +2 -1
- data/spec/lis_spec.rb +3 -2
- data/spec/map_spec.rb +4 -1
- data/spec/maps_spec.rb +1 -1
- data/spec/meta_spec.rb +6 -0
- data/spec/ol_spec.rb +73 -0
- data/spec/ols_spec.rb +41 -0
- data/spec/option_spec.rb +129 -0
- data/spec/p_spec.rb +4 -1
- data/spec/pre_spec.rb +4 -1
- data/spec/pres_spec.rb +1 -1
- data/spec/ps_spec.rb +2 -1
- data/spec/radio_spec.rb +7 -19
- data/spec/radios_spec.rb +1 -1
- data/spec/select_list_spec.rb +19 -57
- data/spec/select_lists_spec.rb +3 -2
- data/spec/span_spec.rb +8 -5
- data/spec/spans_spec.rb +2 -1
- data/spec/spec_helper.rb +8 -43
- data/spec/table_bodies_spec.rb +17 -4
- data/spec/table_body_spec.rb +47 -16
- data/spec/table_cell_spec.rb +5 -3
- data/spec/table_cells_spec.rb +1 -1
- data/spec/table_footer_spec.rb +94 -0
- data/spec/table_footers_spec.rb +53 -0
- data/spec/table_header_spec.rb +94 -0
- data/spec/table_headers_spec.rb +53 -0
- data/spec/table_row_spec.rb +25 -4
- data/spec/table_rows_spec.rb +1 -1
- data/spec/table_spec.rb +22 -2
- data/spec/tables_spec.rb +2 -1
- data/spec/text_field_spec.rb +52 -20
- data/spec/text_fields_spec.rb +1 -1
- data/spec/ul_spec.rb +73 -0
- data/spec/uls_spec.rb +41 -0
- data/spec/watir_compatability_spec.rb +253 -0
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +37 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +19 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +28 -0
- data/support/celerity_viewer/rubycocoa/MainController.rb +23 -0
- data/support/celerity_viewer/rubycocoa/README +94 -0
- data/support/celerity_viewer/rubycocoa/Rakefile +100 -0
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +86 -0
- data/support/celerity_viewer/rubycocoa/main.m +7 -0
- data/support/celerity_viewer/rubycocoa/main.rb +27 -0
- data/support/spec_server.rb +64 -0
- data/tasks/benchmark.rake +1 -0
- data/tasks/rdoc.rake +4 -0
- data/tasks/rspec.rake +10 -3
- data/tasks/simple_ci.rake +94 -0
- data/tasks/specserver.rake +21 -0
- metadata +160 -114
- data/spec/table_bodies.rb +0 -40
- data/tasks/testserver.rake +0 -32
data/spec/select_lists_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe SelectLists do
|
4
|
+
|
4
5
|
before :all do
|
5
6
|
@browser = Celerity::IE.new
|
6
7
|
add_spec_checker(@browser)
|
@@ -18,7 +19,7 @@ describe "SelectLists" do
|
|
18
19
|
|
19
20
|
describe "#[]" do
|
20
21
|
it "should return the correct item" do
|
21
|
-
@browser.select_lists[1].value.should == "
|
22
|
+
@browser.select_lists[1].value.should == "2"
|
22
23
|
@browser.select_lists[1].name.should == "new_user_country"
|
23
24
|
@browser.select_lists[1].type.should == "select-one"
|
24
25
|
@browser.select_lists[2].type.should == "select-multiple"
|
data/spec/span_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Span do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -13,7 +13,7 @@ describe "Span" do
|
|
13
13
|
|
14
14
|
# Exists method
|
15
15
|
describe "#exist?" do
|
16
|
-
it "should return true if the '
|
16
|
+
it "should return true if the 'span' exists" do
|
17
17
|
@browser.span(:id, "lead").should exist
|
18
18
|
@browser.span(:id, /lead/).should exist
|
19
19
|
@browser.span(:text, "Dubito, ergo cogito, ergo sum.").should exist
|
@@ -23,6 +23,9 @@ describe "Span" do
|
|
23
23
|
@browser.span(:index, 1).should exist
|
24
24
|
@browser.span(:xpath, "//span[@id='lead']").should exist
|
25
25
|
end
|
26
|
+
it "should return true if the element exists (default how = :id)" do
|
27
|
+
@browser.span("lead").should exist
|
28
|
+
end
|
26
29
|
it "should return false if the 'p' doesn't exist" do
|
27
30
|
@browser.span(:id, "no_such_id").should_not exist
|
28
31
|
@browser.span(:id, /no_such_id/).should_not exist
|
@@ -87,14 +90,14 @@ describe "Span" do
|
|
87
90
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
88
91
|
@browser.span(:index, 3).title.should == ''
|
89
92
|
end
|
90
|
-
it "should raise UnknownObjectException if the
|
93
|
+
it "should raise UnknownObjectException if the span doesn't exist" do
|
91
94
|
lambda { @browser.span(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
92
95
|
lambda { @browser.span(:xpath, "//span[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
96
99
|
describe "#text" do
|
97
|
-
it "should return the text of the
|
100
|
+
it "should return the text of the span" do
|
98
101
|
@browser.span(:index, 2).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
|
99
102
|
end
|
100
103
|
it "should return an empty string if the element doesn't contain any text" do
|
@@ -113,7 +116,7 @@ describe "Span" do
|
|
113
116
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
114
117
|
@browser.span(:index, 3).value.should == ''
|
115
118
|
end
|
116
|
-
it "should raise UnknownObjectException if the
|
119
|
+
it "should raise UnknownObjectException if the span doesn't exist" do
|
117
120
|
lambda { @browser.span(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
|
118
121
|
lambda { @browser.span(:index , 1337).value }.should raise_error(UnknownObjectException)
|
119
122
|
end
|
data/spec/spans_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -39,48 +39,14 @@ end
|
|
39
39
|
|
40
40
|
if RUBY_PLATFORM =~ /java/ || ENV['WATIR_SPEC']
|
41
41
|
unless defined? WEBRICK_SERVER
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
FileUtils.touch(log_file)
|
48
|
-
end
|
49
|
-
|
50
|
-
server_port = 2000
|
51
|
-
tries = 0
|
52
|
-
begin
|
53
|
-
TEST_HOST = "http://localhost:#{server_port}"
|
54
|
-
server = WEBrick::HTTPServer.new(:Port => server_port,
|
55
|
-
:DocumentRoot => doc_root,
|
56
|
-
:Logger => WEBrick::Log.new(log_file, WEBrick::BasicLog::WARN),
|
57
|
-
:AccessLog => [])
|
58
|
-
rescue Errno::EADDRINUSE => e
|
59
|
-
server_port += 5
|
60
|
-
if tries < 3
|
61
|
-
tries += 1
|
62
|
-
retry
|
63
|
-
else
|
64
|
-
raise e
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class PostServlet < WEBrick::HTTPServlet::AbstractServlet
|
69
|
-
def do_POST(req, resp)
|
70
|
-
resp['content-type'] = 'text/html'
|
71
|
-
resp.body << "<html><body>"
|
72
|
-
resp.body << "You posted the following content:\n"
|
73
|
-
resp.body << req.body
|
74
|
-
resp.body << "</body></html>"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
server.mount("/", WEBrick::HTTPServlet::FileHandler, doc_root, {:FancyIndexing=>true})
|
79
|
-
server.mount("/post_to_me", PostServlet)
|
80
|
-
WEBRICK_SERVER = Thread.new { server.start }
|
42
|
+
# cleaner way to do this?
|
43
|
+
require File.dirname(__FILE__) + "/../support/spec_server"
|
44
|
+
s = Celerity::SpecServer.new
|
45
|
+
s.run
|
46
|
+
TEST_HOST = s.host
|
81
47
|
end
|
82
48
|
else
|
83
|
-
puts "Remember to run \"rake
|
49
|
+
puts "Remember to run \"rake specserver\" before running these tests!"
|
84
50
|
TEST_HOST = "http://localhost:2000"
|
85
51
|
end
|
86
52
|
|
@@ -91,8 +57,7 @@ begin
|
|
91
57
|
if `uname`.chomp == "Darwin" && `ps ax`[/CelerityViewer/]
|
92
58
|
WEB_VIEWER = DRbObject.new_with_uri("druby://127.0.0.1:1337")
|
93
59
|
end
|
94
|
-
rescue IOError
|
95
|
-
rescue Errno::ENOENT
|
60
|
+
rescue IOError, Errno::ENOENT
|
96
61
|
end
|
97
62
|
|
98
63
|
# ================
|
@@ -102,7 +67,7 @@ end
|
|
102
67
|
# define a checker that is run on every page
|
103
68
|
def add_spec_checker(browser)
|
104
69
|
if defined? WEB_VIEWER
|
105
|
-
|
70
|
+
browser.add_checker { WEB_VIEWER.render_html(browser.html, browser.base_url) }
|
106
71
|
end
|
107
72
|
end
|
108
73
|
|
data/spec/table_bodies_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe TableBodies do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -13,20 +13,33 @@ describe "TableBodies" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#length" do
|
16
|
-
it "should return the correct number of table bodies" do
|
16
|
+
it "should return the correct number of table bodies (page context)" do
|
17
|
+
@browser.bodies.length.should == 5
|
18
|
+
end
|
19
|
+
it "should return the correct number of table bodies (table context)" do
|
17
20
|
@browser.table(:index, 1).bodies.length.should == 2
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
24
|
describe "#[]" do
|
22
|
-
it "should return the row at the given index" do
|
25
|
+
it "should return the row at the given index (page context)" do
|
26
|
+
@browser.bodies[1].id.should == "first"
|
27
|
+
@browser.bodies[2].name.should == "second"
|
28
|
+
end
|
29
|
+
it "should return the row at the given index (table context)" do
|
23
30
|
@browser.table(:index, 1).bodies[1].id.should == "first"
|
24
31
|
@browser.table(:index, 1).bodies[2].name.should == "second"
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
28
35
|
describe "#each" do
|
29
|
-
it "should iterate through table bodies correctly" do
|
36
|
+
it "should iterate through table bodies correctly (table context)" do
|
37
|
+
@browser.bodies.each_with_index do |body, index|
|
38
|
+
body.name.should == @browser.tbody(:index, index+1).name
|
39
|
+
body.id.should == @browser.tbody(:index, index+1).id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
it "should iterate through table bodies correctly (table context)" do
|
30
43
|
table = @browser.table(:index, 1)
|
31
44
|
table.bodies.each_with_index do |body, index|
|
32
45
|
body.name.should == table.body(:index, index+1).name
|
data/spec/table_body_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe TableBody do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -13,7 +13,15 @@ describe "TableBody" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#exists" do
|
16
|
-
it "should return true if the table body exists" do
|
16
|
+
it "should return true if the table body exists (page context)" do
|
17
|
+
@browser.body(:id, 'first').should exist
|
18
|
+
@browser.body(:id, /first/).should exist
|
19
|
+
@browser.body(:name, 'second').should exist
|
20
|
+
@browser.body(:name, /second/).should exist
|
21
|
+
@browser.body(:index, 1).should exist
|
22
|
+
@browser.body(:xpath, "//tbody[@id='first']").should exist
|
23
|
+
end
|
24
|
+
it "should return true if the table body exists (table context)" do
|
17
25
|
@browser.table(:index, 1).body(:id, 'first').should exist
|
18
26
|
@browser.table(:index, 1).body(:id, /first/).should exist
|
19
27
|
@browser.table(:index, 1).body(:name, 'second').should exist
|
@@ -21,7 +29,19 @@ describe "TableBody" do
|
|
21
29
|
@browser.table(:index, 1).body(:index, 1).should exist
|
22
30
|
@browser.table(:index, 1).body(:xpath, "//tbody[@id='first']").should exist
|
23
31
|
end
|
24
|
-
it "should return
|
32
|
+
it "should return true if the element exists (default how = :id)" do
|
33
|
+
@browser.body("first").should exist
|
34
|
+
@browser.table(:index, 1).body("first").should exist
|
35
|
+
end
|
36
|
+
it "should return false if the table body exists (page context)" do
|
37
|
+
@browser.body(:id, 'no_such_id').should_not exist
|
38
|
+
@browser.body(:id, /no_such_id/).should_not exist
|
39
|
+
@browser.body(:name, 'no_such_name').should_not exist
|
40
|
+
@browser.body(:name, /no_such_name/).should_not exist
|
41
|
+
@browser.body(:index, 1337).should_not exist
|
42
|
+
@browser.body(:xpath, "//tbody[@id='no_such_id']").should_not exist
|
43
|
+
end
|
44
|
+
it "should return false if the table body exists (table context)" do
|
25
45
|
@browser.table(:index, 1).body(:id, 'no_such_id').should_not exist
|
26
46
|
@browser.table(:index, 1).body(:id, /no_such_id/).should_not exist
|
27
47
|
@browser.table(:index, 1).body(:name, 'no_such_name').should_not exist
|
@@ -30,22 +50,33 @@ describe "TableBody" do
|
|
30
50
|
@browser.table(:index, 1).body(:xpath, "//tbody[@id='no_such_id']").should_not exist
|
31
51
|
end
|
32
52
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
53
|
+
lambda { @browser.body(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
33
54
|
lambda { @browser.table(:index, 1).body(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
34
55
|
end
|
35
56
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
57
|
+
lambda { @browser.body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
36
58
|
lambda { @browser.table(:index, 1).body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
37
59
|
end
|
38
60
|
end
|
39
61
|
|
40
62
|
describe "#length" do
|
41
|
-
it "should return the correct number of table bodies" do
|
63
|
+
it "should return the correct number of table bodies (page context)" do
|
64
|
+
@browser.body(:id, 'first').length.should == 3
|
65
|
+
@browser.body(:name, 'second').length.should == 3
|
66
|
+
end
|
67
|
+
it "should return the correct number of table bodies (table context)" do
|
42
68
|
@browser.table(:index, 1).body(:id, 'first').length.should == 3
|
43
69
|
@browser.table(:index, 1).body(:name, 'second').length.should == 3
|
44
70
|
end
|
45
71
|
end
|
46
72
|
|
47
73
|
describe "#[]" do
|
48
|
-
it "should return the row at the given index" do
|
74
|
+
it "should return the row at the given index (page context)" do
|
75
|
+
@browser.body(:id, 'first')[1].text.should == 'March 2008'
|
76
|
+
@browser.body(:id, 'first')[2][1].text.should == 'Gregory House'
|
77
|
+
@browser.body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
|
78
|
+
end
|
79
|
+
it "should return the row at the given index (table context)" do
|
49
80
|
@browser.table(:index, 1).body(:id, 'first')[1].text.should == 'March 2008'
|
50
81
|
@browser.table(:index, 1).body(:id, 'first')[2][1].text.should == 'Gregory House'
|
51
82
|
@browser.table(:index, 1).body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
|
@@ -53,18 +84,18 @@ describe "TableBody" do
|
|
53
84
|
end
|
54
85
|
|
55
86
|
describe "#each" do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
87
|
+
it "should iterate through rows correctly" do
|
88
|
+
body = @browser.table(:index, 1).body(:id, 'first')
|
89
|
+
index = 1
|
90
|
+
body.each do |r|
|
91
|
+
r.name.should == @browser.row(:index, index).name
|
92
|
+
r.id.should == @browser.row(:index, index).id
|
93
|
+
r.value.should == @browser.row(:index, index).value
|
94
|
+
index += 1
|
95
|
+
end
|
96
|
+
index.should_not == 1
|
67
97
|
end
|
98
|
+
end
|
68
99
|
|
69
100
|
after :all do
|
70
101
|
@browser.close
|
data/spec/table_cell_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe TableCell do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@browser = IE.new
|
@@ -22,6 +22,9 @@ describe "TableCell" do
|
|
22
22
|
@browser.cell(:index, 1).should exist
|
23
23
|
@browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
|
24
24
|
end
|
25
|
+
it "should return true if the element exists (default how = :id)" do
|
26
|
+
@browser.cell("t1_r2_c1").should exist
|
27
|
+
end
|
25
28
|
it "should return false when the table cell does not exist" do
|
26
29
|
@browser.cell(:id, 'no_such_id').should_not exist
|
27
30
|
@browser.cell(:id, /no_such_id/).should_not exist
|
@@ -57,5 +60,4 @@ describe "TableCell" do
|
|
57
60
|
@browser.close
|
58
61
|
end
|
59
62
|
|
60
|
-
|
61
|
-
end
|
63
|
+
end
|
data/spec/table_cells_spec.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe TableFooter do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
|
+
end
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
@browser = IE.new
|
12
|
+
@browser.goto(TEST_HOST + "/tables.html")
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#exists" do
|
16
|
+
it "should return true if the table tfoot exists (page context)" do
|
17
|
+
@browser.tfoot(:id, 'tax_totals').should exist
|
18
|
+
@browser.tfoot(:id, /tax_totals/).should exist
|
19
|
+
@browser.tfoot(:index, 1).should exist
|
20
|
+
@browser.tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
|
21
|
+
end
|
22
|
+
it "should return true if the table tfoot exists (table context)" do
|
23
|
+
@browser.table(:index, 1).tfoot(:id, 'tax_totals').should exist
|
24
|
+
@browser.table(:index, 1).tfoot(:id, /tax_totals/).should exist
|
25
|
+
@browser.table(:index, 1).tfoot(:index, 1).should exist
|
26
|
+
@browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
|
27
|
+
end
|
28
|
+
it "should return true if the element exists (default how = :id)" do
|
29
|
+
@browser.tfoot("tax_totals").should exist
|
30
|
+
@browser.table(:index, 1).tfoot("tax_totals").should exist
|
31
|
+
end
|
32
|
+
it "should return false if the table tfoot exists (page context)" do
|
33
|
+
@browser.tfoot(:id, 'no_such_id').should_not exist
|
34
|
+
@browser.tfoot(:id, /no_such_id/).should_not exist
|
35
|
+
@browser.tfoot(:index, 1337).should_not exist
|
36
|
+
@browser.tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
|
37
|
+
end
|
38
|
+
it "should return false if the table tfoot exists (table context)" do
|
39
|
+
@browser.table(:index, 1).tfoot(:id, 'no_such_id').should_not exist
|
40
|
+
@browser.table(:index, 1).tfoot(:id, /no_such_id/).should_not exist
|
41
|
+
@browser.table(:index, 1).tfoot(:index, 1337).should_not exist
|
42
|
+
@browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
|
43
|
+
end
|
44
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
45
|
+
lambda { @browser.tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
46
|
+
lambda { @browser.table(:index, 1).tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
47
|
+
end
|
48
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
49
|
+
lambda { @browser.tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
50
|
+
lambda { @browser.table(:index, 1).tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#length" do
|
55
|
+
it "should return the correct number of table bodies (page context)" do
|
56
|
+
@browser.tfoot(:id, 'tax_totals').length.should == 1
|
57
|
+
end
|
58
|
+
it "should return the correct number of table bodies (table context)" do
|
59
|
+
@browser.table(:index, 1).tfoot(:id, 'tax_totals').length.should == 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#[]" do
|
64
|
+
it "should return the row at the given index (page context)" do
|
65
|
+
@browser.tfoot(:id, 'tax_totals')[1].text.should == 'Sum 24 349 5 577 18 722'
|
66
|
+
@browser.tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
|
67
|
+
@browser.tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
|
68
|
+
end
|
69
|
+
it "should return the row at the given index (table context)" do
|
70
|
+
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1].text.should == 'Sum 24 349 5 577 18 722'
|
71
|
+
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
|
72
|
+
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#each" do
|
77
|
+
it "should iterate through rows correctly" do
|
78
|
+
tfoot = @browser.table(:index, 1).tfoot(:id, 'tax_totals')
|
79
|
+
index = 1
|
80
|
+
tfoot.each do |r|
|
81
|
+
r.name.should == @browser.row(:index, index).name
|
82
|
+
r.id.should == @browser.row(:index, index).id
|
83
|
+
r.value.should == @browser.row(:index, index).value
|
84
|
+
index += 1
|
85
|
+
end
|
86
|
+
index.should_not == 1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
after :all do
|
91
|
+
@browser.close
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe TableFooters do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
|
+
end
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
@browser = IE.new
|
12
|
+
@browser.goto(TEST_HOST + "/tables.html")
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#length" do
|
16
|
+
it "should return the correct number of table tfoots (page context)" do
|
17
|
+
@browser.tfoots.length.should == 1
|
18
|
+
end
|
19
|
+
it "should return the correct number of table tfoots (table context)" do
|
20
|
+
@browser.table(:index, 1).tfoots.length.should == 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#[]" do
|
25
|
+
it "should return the row at the given index (page context)" do
|
26
|
+
@browser.tfoots[1].id.should == "tax_totals"
|
27
|
+
end
|
28
|
+
it "should return the row at the given index (table context)" do
|
29
|
+
@browser.table(:index, 1).tfoots[1].id.should == "tax_totals"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#each" do
|
34
|
+
it "should iterate through table tfoots correctly (page context)" do
|
35
|
+
@browser.tfoots.each_with_index do |tfoot, index|
|
36
|
+
tfoot.name.should == @browser.tfoot(:index, index+1).name
|
37
|
+
tfoot.id.should == @browser.tfoot(:index, index+1).id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
it "should iterate through table tfoots correctly (table context)" do
|
41
|
+
table = @browser.table(:index, 1)
|
42
|
+
table.tfoots.each_with_index do |tfoot, index|
|
43
|
+
tfoot.name.should == table.tfoot(:index, index+1).name
|
44
|
+
tfoot.id.should == table.tfoot(:index, index+1).id
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
after :all do
|
50
|
+
@browser.close
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|