celerity 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +14 -0
  3. data/Manifest.txt +127 -151
  4. data/README.txt +15 -20
  5. data/lib/celerity.rb +13 -5
  6. data/lib/celerity/browser.rb +296 -0
  7. data/lib/celerity/clickable_element.rb +1 -0
  8. data/lib/celerity/collections.rb +4 -0
  9. data/lib/celerity/container.rb +69 -2
  10. data/lib/celerity/disabled_element.rb +1 -0
  11. data/lib/celerity/element.rb +103 -38
  12. data/lib/celerity/element_collections.rb +14 -8
  13. data/lib/celerity/element_locator.rb +61 -50
  14. data/lib/celerity/element_map.rb +51 -0
  15. data/lib/celerity/elements/button.rb +1 -0
  16. data/lib/celerity/elements/file_field.rb +3 -2
  17. data/lib/celerity/elements/form.rb +1 -0
  18. data/lib/celerity/elements/frame.rb +16 -1
  19. data/lib/celerity/elements/image.rb +15 -13
  20. data/lib/celerity/elements/link.rb +4 -1
  21. data/lib/celerity/elements/option.rb +1 -0
  22. data/lib/celerity/elements/radio_check.rb +19 -7
  23. data/lib/celerity/elements/select_list.rb +17 -2
  24. data/lib/celerity/elements/table.rb +34 -20
  25. data/lib/celerity/elements/table_body.rb +2 -2
  26. data/lib/celerity/elements/table_cell.rb +3 -1
  27. data/lib/celerity/elements/table_footer.rb +2 -2
  28. data/lib/celerity/elements/table_header.rb +2 -2
  29. data/lib/celerity/elements/table_row.rb +4 -2
  30. data/lib/celerity/elements/text_field.rb +20 -9
  31. data/lib/celerity/exception.rb +11 -18
  32. data/lib/celerity/extra/method_generator.rb +13 -8
  33. data/lib/celerity/htmlunit/download.sh +23 -0
  34. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  36. data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
  37. data/lib/celerity/input_element.rb +1 -1
  38. data/lib/celerity/version.rb +1 -1
  39. data/lib/celerity/watir_compatibility.rb +37 -23
  40. data/spec/area_spec.rb +19 -4
  41. data/spec/areas_spec.rb +2 -3
  42. data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
  43. data/spec/button_spec.rb +36 -3
  44. data/spec/buttons_spec.rb +2 -3
  45. data/spec/checkbox_spec.rb +43 -8
  46. data/spec/checkboxes_spec.rb +2 -3
  47. data/spec/div_spec.rb +31 -4
  48. data/spec/divs_spec.rb +2 -3
  49. data/spec/element_spec.rb +36 -6
  50. data/spec/filefield_spec.rb +28 -13
  51. data/spec/filefields_spec.rb +2 -3
  52. data/spec/form_spec.rb +6 -3
  53. data/spec/forms_spec.rb +2 -3
  54. data/spec/frame_spec.rb +14 -5
  55. data/spec/frames_spec.rb +71 -0
  56. data/spec/hidden_spec.rb +21 -3
  57. data/spec/hiddens_spec.rb +2 -3
  58. data/spec/hn_spec.rb +30 -12
  59. data/spec/hns_spec.rb +14 -10
  60. data/spec/html/form_js_bug.html +11 -0
  61. data/spec/html/forms_with_input_elements.html +2 -1
  62. data/spec/html/invalid_js.html +11 -0
  63. data/spec/html/latin1_text.html +1 -0
  64. data/spec/html/non_control_elements.html +8 -4
  65. data/spec/html/simple_ajax.html +22 -0
  66. data/spec/htmlunit_spec.rb +4 -5
  67. data/spec/image_spec.rb +33 -3
  68. data/spec/images_spec.rb +2 -3
  69. data/spec/label_spec.rb +16 -3
  70. data/spec/labels_spec.rb +2 -3
  71. data/spec/li_spec.rb +25 -3
  72. data/spec/link_spec.rb +35 -3
  73. data/spec/links_spec.rb +2 -3
  74. data/spec/lis_spec.rb +2 -3
  75. data/spec/map_spec.rb +19 -3
  76. data/spec/maps_spec.rb +2 -3
  77. data/spec/meta_spec.rb +3 -1
  78. data/spec/ol_spec.rb +17 -3
  79. data/spec/ols_spec.rb +2 -3
  80. data/spec/option_spec.rb +28 -3
  81. data/spec/p_spec.rb +30 -2
  82. data/spec/pre_spec.rb +25 -3
  83. data/spec/pres_spec.rb +2 -3
  84. data/spec/ps_spec.rb +2 -3
  85. data/spec/radio_spec.rb +47 -3
  86. data/spec/radios_spec.rb +2 -3
  87. data/spec/select_list_spec.rb +42 -3
  88. data/spec/select_lists_spec.rb +2 -3
  89. data/spec/span_spec.rb +32 -7
  90. data/spec/spans_spec.rb +2 -4
  91. data/spec/spec_helper.rb +5 -25
  92. data/spec/table_bodies_spec.rb +7 -5
  93. data/spec/table_body_spec.rb +11 -4
  94. data/spec/table_cell_spec.rb +15 -4
  95. data/spec/table_cells_spec.rb +3 -4
  96. data/spec/table_footer_spec.rb +11 -4
  97. data/spec/table_footers_spec.rb +7 -5
  98. data/spec/table_header_spec.rb +11 -4
  99. data/spec/table_headers_spec.rb +7 -5
  100. data/spec/table_row_spec.rb +31 -7
  101. data/spec/table_rows_spec.rb +5 -4
  102. data/spec/table_spec.rb +36 -7
  103. data/spec/tables_spec.rb +2 -3
  104. data/spec/text_field_spec.rb +51 -13
  105. data/spec/text_fields_spec.rb +2 -3
  106. data/spec/ul_spec.rb +18 -3
  107. data/spec/uls_spec.rb +2 -3
  108. data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
  109. data/support/spec_server.rb +9 -0
  110. metadata +167 -161
  111. metadata.gz.sig +0 -0
  112. data/benchmark/bm_2000_spans.rb +0 -48
  113. data/benchmark/bm_digg.rb +0 -26
  114. data/benchmark/bm_google_images.rb +0 -36
  115. data/benchmark/bm_input_locator.rb +0 -69
  116. data/benchmark/loader.rb +0 -9
  117. data/config/hoe.rb +0 -68
  118. data/config/requirements.rb +0 -15
  119. data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
  120. data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
  121. data/lib/celerity/ie.rb +0 -195
  122. data/setup.rb +0 -1583
  123. data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
  124. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
  125. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
  126. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
  127. data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
  128. data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
  129. data/support/celerity_viewer/rubycocoa/README +0 -94
  130. data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
  131. data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
  132. data/support/celerity_viewer/rubycocoa/main.m +0 -7
  133. data/support/celerity_viewer/rubycocoa/main.rb +0 -27
  134. data/tasks/benchmark.rake +0 -4
  135. data/tasks/environment.rake +0 -7
  136. data/tasks/simple_ci.rake +0 -94
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableBodies do
3
+ describe "TableBodies" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -16,6 +15,7 @@ describe TableBodies do
16
15
  it "should return the correct number of table bodies (page context)" do
17
16
  @browser.bodies.length.should == 5
18
17
  end
18
+
19
19
  it "should return the correct number of table bodies (table context)" do
20
20
  @browser.table(:index, 1).bodies.length.should == 2
21
21
  end
@@ -26,6 +26,7 @@ describe TableBodies do
26
26
  @browser.bodies[1].id.should == "first"
27
27
  @browser.bodies[2].name.should == "second"
28
28
  end
29
+
29
30
  it "should return the row at the given index (table context)" do
30
31
  @browser.table(:index, 1).bodies[1].id.should == "first"
31
32
  @browser.table(:index, 1).bodies[2].name.should == "second"
@@ -38,7 +39,8 @@ describe TableBodies do
38
39
  body.name.should == @browser.tbody(:index, index+1).name
39
40
  body.id.should == @browser.tbody(:index, index+1).id
40
41
  end
41
- end
42
+ end
43
+
42
44
  it "should iterate through table bodies correctly (table context)" do
43
45
  table = @browser.table(:index, 1)
44
46
  table.bodies.each_with_index do |body, index|
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableBody do
3
+ describe "TableBody" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -21,6 +20,7 @@ describe TableBody do
21
20
  @browser.body(:index, 1).should exist
22
21
  @browser.body(:xpath, "//tbody[@id='first']").should exist
23
22
  end
23
+
24
24
  it "should return true if the table body exists (table context)" do
25
25
  @browser.table(:index, 1).body(:id, 'first').should exist
26
26
  @browser.table(:index, 1).body(:id, /first/).should exist
@@ -29,10 +29,12 @@ describe TableBody do
29
29
  @browser.table(:index, 1).body(:index, 1).should exist
30
30
  @browser.table(:index, 1).body(:xpath, "//tbody[@id='first']").should exist
31
31
  end
32
+
32
33
  it "should return true if the element exists (default how = :id)" do
33
34
  @browser.body("first").should exist
34
35
  @browser.table(:index, 1).body("first").should exist
35
36
  end
37
+
36
38
  it "should return false if the table body exists (page context)" do
37
39
  @browser.body(:id, 'no_such_id').should_not exist
38
40
  @browser.body(:id, /no_such_id/).should_not exist
@@ -41,6 +43,7 @@ describe TableBody do
41
43
  @browser.body(:index, 1337).should_not exist
42
44
  @browser.body(:xpath, "//tbody[@id='no_such_id']").should_not exist
43
45
  end
46
+
44
47
  it "should return false if the table body exists (table context)" do
45
48
  @browser.table(:index, 1).body(:id, 'no_such_id').should_not exist
46
49
  @browser.table(:index, 1).body(:id, /no_such_id/).should_not exist
@@ -49,10 +52,12 @@ describe TableBody do
49
52
  @browser.table(:index, 1).body(:index, 1337).should_not exist
50
53
  @browser.table(:index, 1).body(:xpath, "//tbody[@id='no_such_id']").should_not exist
51
54
  end
55
+
52
56
  it "should raise ArgumentError when 'what' argument is invalid" do
53
57
  lambda { @browser.body(:id, 3.14).exists? }.should raise_error(ArgumentError)
54
58
  lambda { @browser.table(:index, 1).body(:id, 3.14).exists? }.should raise_error(ArgumentError)
55
59
  end
60
+
56
61
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
57
62
  lambda { @browser.body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
58
63
  lambda { @browser.table(:index, 1).body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
@@ -64,6 +69,7 @@ describe TableBody do
64
69
  @browser.body(:id, 'first').length.should == 3
65
70
  @browser.body(:name, 'second').length.should == 3
66
71
  end
72
+
67
73
  it "should return the correct number of table bodies (table context)" do
68
74
  @browser.table(:index, 1).body(:id, 'first').length.should == 3
69
75
  @browser.table(:index, 1).body(:name, 'second').length.should == 3
@@ -76,6 +82,7 @@ describe TableBody do
76
82
  @browser.body(:id, 'first')[2][1].text.should == 'Gregory House'
77
83
  @browser.body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
78
84
  end
85
+
79
86
  it "should return the row at the given index (table context)" do
80
87
  @browser.table(:index, 1).body(:id, 'first')[1].text.should == 'March 2008'
81
88
  @browser.table(:index, 1).body(:id, 'first')[2][1].text.should == 'Gregory House'
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableCell do
3
+ describe "TableCell" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -22,9 +21,11 @@ describe TableCell do
22
21
  @browser.cell(:index, 1).should exist
23
22
  @browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
24
23
  end
24
+
25
25
  it "should return true if the element exists (default how = :id)" do
26
26
  @browser.cell("t1_r2_c1").should exist
27
27
  end
28
+
28
29
  it "should return false when the table cell does not exist" do
29
30
  @browser.cell(:id, 'no_such_id').should_not exist
30
31
  @browser.cell(:id, /no_such_id/).should_not exist
@@ -33,9 +34,11 @@ describe TableCell do
33
34
  @browser.cell(:index, 1337).should_not exist
34
35
  @browser.cell(:xpath, "//td[@id='no_such_id']").should_not exist
35
36
  end
37
+
36
38
  it "should raise ArgumentError when 'what' argument is invalid" do
37
39
  lambda { @browser.cell(:id, 3.14).exists? }.should raise_error(ArgumentError)
38
40
  end
41
+
39
42
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
40
43
  lambda { @browser.cell(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
41
44
  end
@@ -56,6 +59,14 @@ describe TableCell do
56
59
  end
57
60
  end
58
61
 
62
+ describe "#respond_to?" do
63
+ it "should return true for all attribute methods" do
64
+ @browser.cell(:index, 1).should respond_to(:text)
65
+ @browser.cell(:index, 1).should respond_to(:colspan)
66
+ end
67
+ end
68
+
69
+
59
70
  after :all do
60
71
  @browser.close
61
72
  end
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableCells do
3
+ describe "TableCells" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableFooter do
3
+ describe "TableFooter" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -19,32 +18,38 @@ describe TableFooter do
19
18
  @browser.tfoot(:index, 1).should exist
20
19
  @browser.tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
21
20
  end
21
+
22
22
  it "should return true if the table tfoot exists (table context)" do
23
23
  @browser.table(:index, 1).tfoot(:id, 'tax_totals').should exist
24
24
  @browser.table(:index, 1).tfoot(:id, /tax_totals/).should exist
25
25
  @browser.table(:index, 1).tfoot(:index, 1).should exist
26
26
  @browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
27
27
  end
28
+
28
29
  it "should return true if the element exists (default how = :id)" do
29
30
  @browser.tfoot("tax_totals").should exist
30
31
  @browser.table(:index, 1).tfoot("tax_totals").should exist
31
32
  end
33
+
32
34
  it "should return false if the table tfoot exists (page context)" do
33
35
  @browser.tfoot(:id, 'no_such_id').should_not exist
34
36
  @browser.tfoot(:id, /no_such_id/).should_not exist
35
37
  @browser.tfoot(:index, 1337).should_not exist
36
38
  @browser.tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
37
39
  end
40
+
38
41
  it "should return false if the table tfoot exists (table context)" do
39
42
  @browser.table(:index, 1).tfoot(:id, 'no_such_id').should_not exist
40
43
  @browser.table(:index, 1).tfoot(:id, /no_such_id/).should_not exist
41
44
  @browser.table(:index, 1).tfoot(:index, 1337).should_not exist
42
45
  @browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
43
46
  end
47
+
44
48
  it "should raise ArgumentError when 'what' argument is invalid" do
45
49
  lambda { @browser.tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
46
50
  lambda { @browser.table(:index, 1).tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
47
51
  end
52
+
48
53
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
49
54
  lambda { @browser.tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
50
55
  lambda { @browser.table(:index, 1).tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
@@ -55,6 +60,7 @@ describe TableFooter do
55
60
  it "should return the correct number of table bodies (page context)" do
56
61
  @browser.tfoot(:id, 'tax_totals').length.should == 1
57
62
  end
63
+
58
64
  it "should return the correct number of table bodies (table context)" do
59
65
  @browser.table(:index, 1).tfoot(:id, 'tax_totals').length.should == 1
60
66
  end
@@ -66,6 +72,7 @@ describe TableFooter do
66
72
  @browser.tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
67
73
  @browser.tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
68
74
  end
75
+
69
76
  it "should return the row at the given index (table context)" do
70
77
  @browser.table(:index, 1).tfoot(:id, 'tax_totals')[1].text.should == 'Sum 24 349 5 577 18 722'
71
78
  @browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableFooters do
3
+ describe "TableFooters" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -16,6 +15,7 @@ describe TableFooters do
16
15
  it "should return the correct number of table tfoots (page context)" do
17
16
  @browser.tfoots.length.should == 1
18
17
  end
18
+
19
19
  it "should return the correct number of table tfoots (table context)" do
20
20
  @browser.table(:index, 1).tfoots.length.should == 1
21
21
  end
@@ -25,6 +25,7 @@ describe TableFooters do
25
25
  it "should return the row at the given index (page context)" do
26
26
  @browser.tfoots[1].id.should == "tax_totals"
27
27
  end
28
+
28
29
  it "should return the row at the given index (table context)" do
29
30
  @browser.table(:index, 1).tfoots[1].id.should == "tax_totals"
30
31
  end
@@ -36,7 +37,8 @@ describe TableFooters do
36
37
  tfoot.name.should == @browser.tfoot(:index, index+1).name
37
38
  tfoot.id.should == @browser.tfoot(:index, index+1).id
38
39
  end
39
- end
40
+ end
41
+
40
42
  it "should iterate through table tfoots correctly (table context)" do
41
43
  table = @browser.table(:index, 1)
42
44
  table.tfoots.each_with_index do |tfoot, index|
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableHeader do
3
+ describe "TableHeader" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -19,32 +18,38 @@ describe TableHeader do
19
18
  @browser.thead(:index, 1).should exist
20
19
  @browser.thead(:xpath, "//thead[@id='tax_headers']").should exist
21
20
  end
21
+
22
22
  it "should return true if the table theader exists (table context)" do
23
23
  @browser.table(:index, 1).thead(:id, 'tax_headers').should exist
24
24
  @browser.table(:index, 1).thead(:id, /tax_headers/).should exist
25
25
  @browser.table(:index, 1).thead(:index, 1).should exist
26
26
  @browser.table(:index, 1).thead(:xpath, "//thead[@id='tax_headers']").should exist
27
27
  end
28
+
28
29
  it "should return true if the element exists (default how = :id)" do
29
30
  @browser.thead("tax_headers").should exist
30
31
  @browser.table(:index, 1).thead("tax_headers").should exist
31
32
  end
33
+
32
34
  it "should return false if the table theader exists (page context)" do
33
35
  @browser.thead(:id, 'no_such_id').should_not exist
34
36
  @browser.thead(:id, /no_such_id/).should_not exist
35
37
  @browser.thead(:index, 1337).should_not exist
36
38
  @browser.thead(:xpath, "//thead[@id='no_such_id']").should_not exist
37
39
  end
40
+
38
41
  it "should return false if the table theader exists (table context)" do
39
42
  @browser.table(:index, 1).thead(:id, 'no_such_id').should_not exist
40
43
  @browser.table(:index, 1).thead(:id, /no_such_id/).should_not exist
41
44
  @browser.table(:index, 1).thead(:index, 1337).should_not exist
42
45
  @browser.table(:index, 1).thead(:xpath, "//thead[@id='no_such_id']").should_not exist
43
46
  end
47
+
44
48
  it "should raise ArgumentError when 'what' argument is invalid" do
45
49
  lambda { @browser.thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
46
50
  lambda { @browser.table(:index, 1).thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
47
51
  end
52
+
48
53
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
49
54
  lambda { @browser.thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
50
55
  lambda { @browser.table(:index, 1).thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
@@ -55,6 +60,7 @@ describe TableHeader do
55
60
  it "should return the correct number of table bodies (page context)" do
56
61
  @browser.thead(:id, 'tax_headers').length.should == 1
57
62
  end
63
+
58
64
  it "should return the correct number of table bodies (table context)" do
59
65
  @browser.table(:index, 1).thead(:id, 'tax_headers').length.should == 1
60
66
  end
@@ -66,6 +72,7 @@ describe TableHeader do
66
72
  @browser.thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
67
73
  @browser.thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
68
74
  end
75
+
69
76
  it "should return the row at the given index (table context)" do
70
77
  @browser.table(:index, 1).thead(:id, 'tax_headers')[1].text.should == 'Before income tax Income tax After income tax'
71
78
  @browser.table(:index, 1).thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableHeaders do
3
+ describe "TableHeaders" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -16,6 +15,7 @@ describe TableHeaders do
16
15
  it "should return the correct number of table theads (page context)" do
17
16
  @browser.theads.length.should == 1
18
17
  end
18
+
19
19
  it "should return the correct number of table theads (table context)" do
20
20
  @browser.table(:index, 1).theads.length.should == 1
21
21
  end
@@ -25,6 +25,7 @@ describe TableHeaders do
25
25
  it "should return the row at the given index (page context)" do
26
26
  @browser.theads[1].id.should == "tax_headers"
27
27
  end
28
+
28
29
  it "should return the row at the given index (table context)" do
29
30
  @browser.table(:index, 1).theads[1].id.should == "tax_headers"
30
31
  end
@@ -36,7 +37,8 @@ describe TableHeaders do
36
37
  thead.name.should == @browser.thead(:index, index+1).name
37
38
  thead.id.should == @browser.thead(:index, index+1).id
38
39
  end
39
- end
40
+ end
41
+
40
42
  it "should iterate through table theads correctly (table context)" do
41
43
  table = @browser.table(:index, 1)
42
44
  table.theads.each_with_index do |thead, index|
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableRow do
3
+ describe "TableRow" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -19,15 +18,22 @@ describe TableRow do
19
18
  @browser.row(:index, 1).should exist
20
19
  @browser.row(:xpath, "//tr[@id='outer_first']")
21
20
  end
21
+
22
22
  it "should return true if the element exists (default how = :id)" do
23
23
  @browser.row("outer_last").should exist
24
24
  end
25
+
25
26
  it "should return false if the table row exists" do
26
-
27
+ @browser.row(:id, "no_such_id").should_not exist
28
+ @browser.row(:id, /no_such_id/).should_not exist
29
+ @browser.row(:index, 1337).should_not exist
30
+ @browser.row(:xpath, "//tr[@id='no_such_id']")
27
31
  end
32
+
28
33
  it "should raise ArgumentError when 'what' argument is invalid" do
29
34
  lambda { @browser.row(:id, 3.14).exists? }.should raise_error(ArgumentError)
30
35
  end
36
+
31
37
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
32
38
  lambda { @browser.row(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
33
39
  end
@@ -51,15 +57,33 @@ describe TableRow do
51
57
  end
52
58
 
53
59
  describe "#[]" do
54
- it "should " do # FIXME: description
60
+ it "should return the nth cell of the parent row" do
55
61
  @browser.table(:id, 'outer').row(:index, 1)[1].text.should == "Table 1, Row 1, Cell 1"
56
62
  @browser.table(:id, 'outer')[1][1].text.should == "Table 1, Row 1, Cell 1"
57
63
  @browser.table(:id, 'outer')[3][1].text.should == "Table 1, Row 3, Cell 1"
58
64
  end
65
+
66
+ it "should raise UnknownCellException if the index is out of bounds" do
67
+ lambda { @browser.table(:id, 'outer').row(:index, 1)[1337] }.should raise_error(UnknownCellException)
68
+ lambda { @browser.table(:id, 'outer')[1][1337] }.should raise_error(UnknownCellException)
69
+ end
70
+ end
71
+
72
+ describe "#child_cell" do
73
+ it "should return the nth cell of the parent row" do
74
+ @browser.table(:id, 'outer').row(:index, 1).child_cell(1).text.should == "Table 1, Row 1, Cell 1"
75
+ @browser.table(:id, 'outer')[1].child_cell(1).text.should == "Table 1, Row 1, Cell 1"
76
+ @browser.table(:id, 'outer')[3].child_cell(1).text.should == "Table 1, Row 3, Cell 1"
77
+ end
78
+
79
+ it "should raise UnknownCellException if the index is out of bounds" do
80
+ lambda { @browser.table(:id, 'outer').row(:index, 1).child_cell(1337) }.should raise_error(UnknownCellException)
81
+ lambda { @browser.table(:id, 'outer')[1].child_cell(1337) }.should raise_error(UnknownCellException)
82
+ end
59
83
  end
60
84
 
61
85
  describe "#each" do
62
- it "should " do # FIXME: description
86
+ it "should iterate correctly through the cells of the row" do
63
87
  index = 1
64
88
  @browser.table(:id, 'outer')[2].each do |c|
65
89
  case index