symbiont 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Gemfile.lock +22 -7
  2. data/HISTORY.md +6 -0
  3. data/app/public/css/site.css +16 -0
  4. data/app/public/js/site.js +3 -1
  5. data/app/views/comics.erb +23 -1
  6. data/app/views/webobject.erb +1 -1
  7. data/lib/symbiont/data_setter.rb +7 -3
  8. data/lib/symbiont/enclosers.rb +24 -27
  9. data/lib/symbiont/evaluators.rb +52 -23
  10. data/lib/symbiont/factory.rb +19 -75
  11. data/lib/symbiont/generators.rb +172 -44
  12. data/lib/symbiont/platform_watir/platform_object.rb +202 -18
  13. data/lib/symbiont/version.rb +1 -1
  14. data/lib/symbiont/web_objects/button.rb +1 -1
  15. data/lib/symbiont/web_objects/checkbox.rb +1 -1
  16. data/lib/symbiont/web_objects/heading.rb +12 -0
  17. data/lib/symbiont/web_objects/hidden_field.rb +19 -0
  18. data/lib/symbiont/web_objects/label.rb +15 -0
  19. data/lib/symbiont/web_objects/list_item.rb +13 -0
  20. data/lib/symbiont/web_objects/ordered_list.rb +49 -0
  21. data/lib/symbiont/web_objects/radio.rb +1 -1
  22. data/lib/symbiont/web_objects/select_list.rb +1 -1
  23. data/lib/symbiont/web_objects/table.rb +4 -0
  24. data/lib/symbiont/web_objects/table_row.rb +4 -0
  25. data/lib/symbiont/web_objects/text_area.rb +26 -0
  26. data/lib/symbiont/web_objects/unordered_list.rb +49 -0
  27. data/lib/symbiont.rb +7 -0
  28. data/lucid.yml +6 -0
  29. data/spec/spec_helper.rb +70 -16
  30. data/spec/symbiont/data_setter_spec.rb +65 -62
  31. data/spec/symbiont/enclosers_spec.rb +76 -57
  32. data/spec/symbiont/evaluators_spec.rb +95 -75
  33. data/spec/symbiont/factory_spec.rb +174 -122
  34. data/spec/symbiont/generators/button_generators_spec.rb +34 -31
  35. data/spec/symbiont/generators/checkbox_generators_spec.rb +79 -75
  36. data/spec/symbiont/generators/div_generators_spec.rb +56 -52
  37. data/spec/symbiont/generators/hidden_field_generators_spec.rb +65 -0
  38. data/spec/symbiont/generators/link_generators_spec.rb +30 -27
  39. data/spec/symbiont/generators/paragraph_generators_spec.rb +22 -17
  40. data/spec/symbiont/generators/radio_generators_spec.rb +76 -77
  41. data/spec/symbiont/generators/select_list_generators_spec.rb +93 -77
  42. data/spec/symbiont/generators/span_generators_spec.rb +56 -52
  43. data/spec/symbiont/generators/{cell_generators_spec.rb → table_cell_generators_spec.rb} +56 -52
  44. data/spec/symbiont/generators/table_generators_spec.rb +56 -52
  45. data/spec/symbiont/generators/text_area_generators_spec.rb +72 -0
  46. data/spec/symbiont/generators/text_field_generators_spec.rb +30 -27
  47. data/spec/symbiont/generators_spec.rb +38 -28
  48. data/spec/symbiont/locators_spec.rb +68 -68
  49. data/spec/symbiont/platform_object_spec.rb +2 -4
  50. data/spec/symbiont/symbiont_spec.rb +10 -8
  51. data/spec/symbiont/web_object_spec.rb +194 -194
  52. data/spec/symbiont/web_objects/button_spec.rb +38 -30
  53. data/spec/symbiont/web_objects/checkbox_spec.rb +27 -27
  54. data/spec/symbiont/web_objects/div_spec.rb +18 -11
  55. data/spec/symbiont/web_objects/heading_spec.rb +22 -0
  56. data/spec/symbiont/web_objects/hidden_field_spec.rb +18 -0
  57. data/spec/symbiont/web_objects/label_spec.rb +18 -0
  58. data/spec/symbiont/web_objects/link_spec.rb +33 -33
  59. data/spec/symbiont/web_objects/list_item_spec.rb +18 -0
  60. data/spec/symbiont/web_objects/option_spec.rb +9 -9
  61. data/spec/symbiont/web_objects/ordered_list_spec.rb +53 -0
  62. data/spec/symbiont/web_objects/paragraph_spec.rb +9 -2
  63. data/spec/symbiont/web_objects/radio_spec.rb +27 -27
  64. data/spec/symbiont/web_objects/select_list_spec.rb +69 -69
  65. data/spec/symbiont/web_objects/span_spec.rb +18 -11
  66. data/spec/symbiont/web_objects/table_cell_spec.rb +19 -19
  67. data/spec/symbiont/web_objects/table_row_spec.rb +58 -58
  68. data/spec/symbiont/web_objects/table_spec.rb +61 -61
  69. data/spec/symbiont/web_objects/text_area_spec.rb +18 -0
  70. data/spec/symbiont/web_objects/text_field_spec.rb +39 -39
  71. data/spec/symbiont/web_objects/unordered_list_spec.rb +51 -0
  72. data/specs/common/support/browser.rb +25 -0
  73. data/specs/common/support/env.rb +6 -0
  74. data/specs/common/support/events.rb +15 -0
  75. data/specs/enclosers.feature +9 -0
  76. data/specs/evaluators.feature +26 -0
  77. data/specs/pages/characters.rb +22 -0
  78. data/specs/pages/home.rb +9 -0
  79. data/specs/pages/stardate.rb +23 -0
  80. data/specs/pages/web_objects.rb +77 -0
  81. data/specs/select_list.feature +53 -0
  82. data/specs/steps/enclosers_steps.rb +17 -0
  83. data/specs/steps/evaluators_steps.rb +44 -0
  84. data/specs/steps/navigation_steps.rb +14 -0
  85. data/specs/steps/select_list_steps.rb +94 -0
  86. data/specs/steps/table_cell_steps.rb +31 -0
  87. data/specs/steps/table_steps.rb +87 -0
  88. data/specs/table.feature +49 -0
  89. data/specs/table_cell.feature +27 -0
  90. data/symbiont.gemspec +4 -1
  91. metadata +72 -6
  92. data/cucumber.yml +0 -6
@@ -1,33 +1,33 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::Link do
4
- describe "implementation" do
5
- let(:link_object) { double('link_object') }
6
- let(:link) { Symbiont::WebObjects::Link }
7
-
8
- it "should reference standard usable selectors" do
9
- [:class, :id, :name, :index, :xpath].each do |s|
10
- locator = link.provide_locator_for s => 'value'
11
- locator.keys.first.should == s
12
- end
13
- end
14
-
15
- it "should reference specific usable selectors" do
16
- [:href, :text, :title, :css].each do |s|
17
- locator = link.provide_locator_for s => 'value'
18
- locator.keys.first.should == s
19
- end
20
- end
21
-
22
- it "should reference mappable selectors" do
23
- [:link, :link_text].each do |s|
24
- locator = link.provide_locator_for s => 'value'
25
- locator.keys.first.should == :text
26
- end
27
- end
28
-
29
- it "should register with an anchor tag" do
30
- ::Symbiont::WebObjects.get_class_for(:a).should == ::Symbiont::WebObjects::Link
31
- end
32
- end
33
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Link do
4
+ describe "implementation" do
5
+ let(:link_object) { double('link_object') }
6
+ let(:link) { Symbiont::WebObjects::Link }
7
+
8
+ it "should reference standard usable selectors" do
9
+ [:class, :id, :name, :index, :xpath].each do |s|
10
+ locator = link.provide_locator_for s => 'value'
11
+ locator.keys.first.should == s
12
+ end
13
+ end
14
+
15
+ it "should reference specific usable selectors" do
16
+ [:href, :text, :title, :css].each do |s|
17
+ locator = link.provide_locator_for s => 'value'
18
+ locator.keys.first.should == s
19
+ end
20
+ end
21
+
22
+ it "should reference mappable selectors" do
23
+ [:link, :link_text].each do |s|
24
+ locator = link.provide_locator_for s => 'value'
25
+ locator.keys.first.should == :text
26
+ end
27
+ end
28
+
29
+ it "should register with an anchor tag" do
30
+ ::Symbiont::WebObjects.get_class_for(:a).should == ::Symbiont::WebObjects::Link
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::ListItem do
4
+ describe "implementation" do
5
+ let(:list_item_object) { Symbiont::WebObjects::ListItem }
6
+
7
+ it "should allow locators to be used" do
8
+ [:class, :id, :index, :xpath, :name, :text].each do |t|
9
+ locator = list_item_object.provide_locator_for t => 'value'
10
+ locator.keys.first.should == t
11
+ end
12
+ end
13
+
14
+ it "should register with a list item (li) tag" do
15
+ ::Symbiont::WebObjects.get_class_for(:li).should == ::Symbiont::WebObjects::ListItem
16
+ end
17
+ end
18
+ end
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::Option do
4
- describe "implementation" do
5
- it "should register with an option tag" do
6
- ::Symbiont::WebObjects.get_class_for(:option).should == ::Symbiont::WebObjects::Option
7
- end
8
- end
9
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Option do
4
+ describe "implementation" do
5
+ it "should register with an option tag" do
6
+ ::Symbiont::WebObjects.get_class_for(:option).should == ::Symbiont::WebObjects::Option
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::OrderedList do
4
+ describe "implementation" do
5
+ let(:ordered_list_object) { Symbiont::WebObjects::OrderedList }
6
+
7
+ it "should allow locators to be used" do
8
+ [:class, :id, :index, :xpath, :name].each do |t|
9
+ locator = ordered_list_object.provide_locator_for t => 'value'
10
+ locator.keys.first.should == t
11
+ end
12
+ end
13
+
14
+ it "should register with a ordered list (ol) tag" do
15
+ ::Symbiont::WebObjects.get_class_for(:ol).should == ::Symbiont::WebObjects::OrderedList
16
+ end
17
+
18
+ context "on the watir platform" do
19
+ let(:ol_element) { double('ol_element') }
20
+ let(:watir_ordered_list) { Symbiont::WebObjects::OrderedList.new(ol_element) }
21
+
22
+ it "should return a list item when indexed" do
23
+ ol_element.stub(:ols).and_return([ol_element])
24
+ ol_element.stub(:find_elements).and_return(ol_element)
25
+ ol_element.stub(:map).and_return([ol_element])
26
+ ol_element.stub(:parent).and_return(ol_element)
27
+ ol_element.stub(:element).and_return(ol_element)
28
+ ol_element.stub(:==).and_return(true)
29
+ watir_ordered_list[1]
30
+ end
31
+
32
+ it "should know how many list items it contains" do
33
+ ol_element.stub(:ols).and_return([ol_element])
34
+ ol_element.stub(:find_elements).and_return(ol_element)
35
+ ol_element.stub(:map).and_return([ol_element])
36
+ ol_element.stub(:parent).and_return(ol_element)
37
+ ol_element.stub(:element).and_return(ol_element)
38
+ ol_element.stub(:==).and_return(true)
39
+ watir_ordered_list.items.should == 1
40
+ end
41
+
42
+ it "should iterate over the list items" do
43
+ watir_ordered_list.should_receive(:items).and_return(5)
44
+ watir_ordered_list.stub(:[])
45
+ count = 0
46
+ watir_ordered_list.each { |item| count += 1 }
47
+ count.should == 5
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -2,9 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe Symbiont::WebObjects::Paragraph do
4
4
  describe "implementation" do
5
- let(:p_object) { double('p_object') }
5
+ let(:p_object) { Symbiont::WebObjects::Paragraph }
6
6
 
7
- it "should register with a paragraph tag" do
7
+ it "should allow locators to be used" do
8
+ [:class, :id, :index, :xpath, :name].each do |t|
9
+ locator = p_object.provide_locator_for t => 'value'
10
+ locator.keys.first.should == t
11
+ end
12
+ end
13
+
14
+ it "should register with a paragraph (p) tag" do
8
15
  ::Symbiont::WebObjects.get_class_for(:p).should == ::Symbiont::WebObjects::Paragraph
9
16
  end
10
17
  end
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::Radio do
4
- describe "implementation" do
5
- let(:radio_object) { double('radio_object') }
6
- let(:radio) { Symbiont::WebObjects::Radio.new(radio_object) }
7
-
8
- it "should register with a radio type" do
9
- ::Symbiont::WebObjects.get_class_for(:input, :radio).should == ::Symbiont::WebObjects::Radio
10
- end
11
-
12
- it "should be able to select a radio" do
13
- radio_object.should_receive(:set).and_return(true)
14
- radio.select
15
- end
16
-
17
- it "should be able to clear a radio" do
18
- radio_object.should_receive(:clear).and_return(true)
19
- radio.clear
20
- end
21
-
22
- it "should be able to see if a radio is selected" do
23
- radio_object.should_receive(:set?).and_return(true)
24
- radio.selected?
25
- end
26
- end
27
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Radio do
4
+ describe "implementation" do
5
+ let(:radio_object) { double('radio_object') }
6
+ let(:radio) { Symbiont::WebObjects::Radio.new(radio_object) }
7
+
8
+ it "should register with a radio type" do
9
+ ::Symbiont::WebObjects.get_class_for(:input, :radio).should == ::Symbiont::WebObjects::Radio
10
+ end
11
+
12
+ it "should be able to select a radio" do
13
+ radio_object.should_receive(:set).and_return(true)
14
+ radio.select
15
+ end
16
+
17
+ it "should be able to clear a radio" do
18
+ radio_object.should_receive(:clear).and_return(true)
19
+ radio.clear
20
+ end
21
+
22
+ it "should be able to see if a radio is selected" do
23
+ radio_object.should_receive(:set?).and_return(true)
24
+ radio.selected?
25
+ end
26
+ end
27
+ end
@@ -1,69 +1,69 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::SelectList do
4
- describe "implementation" do
5
- let(:select_list_object) { double('select_list_object') }
6
- let(:select_list) { Symbiont::WebObjects::SelectList }
7
- let(:select_list_actual) { Symbiont::WebObjects::SelectList.new(select_list_object) }
8
- let(:list_opts) { [select_list_object, select_list_object] }
9
-
10
- before(:each) do
11
- select_list_object.stub(:find_elements).and_return(select_list_object)
12
- select_list_object.stub(:wd).and_return(select_list_object)
13
- select_list_object.stub(:include?)
14
- end
15
-
16
- it "should reference standard usable selectors" do
17
- [:class, :id, :name, :index, :xpath].each do |s|
18
- locator = select_list.provide_locator_for s => 'value'
19
- locator.keys.first.should == s
20
- end
21
- end
22
-
23
- it "should register with a select list tag" do
24
- ::Symbiont::WebObjects.get_class_for(:select).should == ::Symbiont::WebObjects::SelectList
25
- end
26
-
27
- it "should return an option when indexed" do
28
- select_list_object.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(list_opts)
29
- select_list_actual[0].should be_instance_of Symbiont::WebObjects::Option
30
- end
31
-
32
- it "should return an array of options" do
33
- select_list_object.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(list_opts)
34
- select_list_actual.options.size.should == 2
35
- end
36
-
37
- it "should return an array of selected options" do
38
- select_list_object.stub(:selected_options).and_return(list_opts)
39
- select_list_object.stub(:text).and_return(select_list_object)
40
- select_list_actual.selected_options.should == list_opts
41
- end
42
-
43
- it "should determine if an option is selected" do
44
- select_list_object.stub(:selected?).with('testing').and_return(true)
45
- select_list_actual.selected?('testing')
46
- end
47
-
48
- it "should determine if an option is available" do
49
- select_list_object.stub(:include?).with('testing').and_return(true)
50
- select_list_actual.include?('testing')
51
- end
52
-
53
- it "should get the values for any selected options" do
54
- select_list_object.stub(:selected_options).and_return(list_opts)
55
- select_list_object.stub(:value).and_return(select_list_object)
56
- select_list_actual.selected_values.should == list_opts
57
- end
58
-
59
- it "should be able to select an item by value" do
60
- select_list_object.should_receive(:select_value).and_return(true)
61
- select_list_actual.select_value('testing')
62
- end
63
-
64
- it "should be able to select an item by option" do
65
- select_list_object.should_receive(:select).and_return(true)
66
- select_list_actual.select('testing')
67
- end
68
- end
69
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::SelectList do
4
+ describe "implementation" do
5
+ let(:select_list_object) { double('select_list_object') }
6
+ let(:select_list) { Symbiont::WebObjects::SelectList }
7
+ let(:select_list_actual) { Symbiont::WebObjects::SelectList.new(select_list_object) }
8
+ let(:list_opts) { [select_list_object, select_list_object] }
9
+
10
+ before(:each) do
11
+ select_list_object.stub(:find_elements).and_return(select_list_object)
12
+ select_list_object.stub(:wd).and_return(select_list_object)
13
+ select_list_object.stub(:include?)
14
+ end
15
+
16
+ it "should reference standard usable selectors" do
17
+ [:class, :id, :name, :index, :xpath].each do |s|
18
+ locator = select_list.provide_locator_for s => 'value'
19
+ locator.keys.first.should == s
20
+ end
21
+ end
22
+
23
+ it "should register with a select list tag" do
24
+ ::Symbiont::WebObjects.get_class_for(:select).should == ::Symbiont::WebObjects::SelectList
25
+ end
26
+
27
+ it "should return an option when indexed" do
28
+ select_list_object.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(list_opts)
29
+ select_list_actual[0].should be_instance_of Symbiont::WebObjects::Option
30
+ end
31
+
32
+ it "should return an array of options" do
33
+ select_list_object.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(list_opts)
34
+ select_list_actual.options.size.should == 2
35
+ end
36
+
37
+ it "should return an array of selected options" do
38
+ select_list_object.stub(:selected_options).and_return(list_opts)
39
+ select_list_object.stub(:text).and_return(select_list_object)
40
+ select_list_actual.selected_options.should == list_opts
41
+ end
42
+
43
+ it "should determine if an option is selected" do
44
+ select_list_object.stub(:selected?).with('testing').and_return(true)
45
+ select_list_actual.selected?('testing')
46
+ end
47
+
48
+ it "should determine if an option is available" do
49
+ select_list_object.stub(:include?).with('testing').and_return(true)
50
+ select_list_actual.include?('testing')
51
+ end
52
+
53
+ it "should get the values for any selected options" do
54
+ select_list_object.stub(:selected_options).and_return(list_opts)
55
+ select_list_object.stub(:value).and_return(select_list_object)
56
+ select_list_actual.selected_values.should == list_opts
57
+ end
58
+
59
+ it "should be able to select an item by value" do
60
+ select_list_object.should_receive(:select_value).and_return(true)
61
+ select_list_actual.select_value('testing')
62
+ end
63
+
64
+ it "should be able to select an item by option" do
65
+ select_list_object.should_receive(:select).and_return(true)
66
+ select_list_actual.select('testing')
67
+ end
68
+ end
69
+ end
@@ -1,11 +1,18 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::Span do
4
- describe "implementation" do
5
- let(:span_object) { double('span_object') }
6
-
7
- it "should register with a span tag" do
8
- ::Symbiont::WebObjects.get_class_for(:span).should == ::Symbiont::WebObjects::Span
9
- end
10
- end
11
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::Span do
4
+ describe "implementation" do
5
+ let(:span_object) { Symbiont::WebObjects::Span }
6
+
7
+ it "should allow locators to be used" do
8
+ [:class, :id, :text, :index, :xpath, :title, :name].each do |t|
9
+ locator = span_object.provide_locator_for t => 'value'
10
+ locator.keys.first.should == t
11
+ end
12
+ end
13
+
14
+ it "should register with a span tag" do
15
+ ::Symbiont::WebObjects.get_class_for(:span).should == ::Symbiont::WebObjects::Span
16
+ end
17
+ end
18
+ end
@@ -1,19 +1,19 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::TableCell do
4
- describe "implementation" do
5
- it "should register with a table definition tag" do
6
- ::Symbiont::WebObjects.get_class_for(:td).should == ::Symbiont::WebObjects::TableCell
7
- end
8
-
9
- it "should register with a table header tag" do
10
- ::Symbiont::WebObjects.get_class_for(:th).should == ::Symbiont::WebObjects::TableCell
11
- end
12
-
13
- it "should always be enabled" do
14
- table_cell_object = double('table_cell_object')
15
- table_cell = Symbiont::WebObjects::TableCell.new(table_cell_object)
16
- table_cell.enabled?.should be_true
17
- end
18
- end
19
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::TableCell do
4
+ describe "implementation" do
5
+ it "should register with a table definition tag" do
6
+ ::Symbiont::WebObjects.get_class_for(:td).should == ::Symbiont::WebObjects::TableCell
7
+ end
8
+
9
+ it "should register with a table header tag" do
10
+ ::Symbiont::WebObjects.get_class_for(:th).should == ::Symbiont::WebObjects::TableCell
11
+ end
12
+
13
+ it "should always be enabled" do
14
+ table_cell_object = double('table_cell_object')
15
+ table_cell = Symbiont::WebObjects::TableCell.new(table_cell_object)
16
+ table_cell.enabled?.should be_true
17
+ end
18
+ end
19
+ end
@@ -1,58 +1,58 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::WebObjects::TableRow do
4
- describe "implementation" do
5
- let(:table_cell) { double('table_cell') }
6
- let(:table_row_object) { double('table_row_object') }
7
-
8
- context "on the watir platform" do
9
- it "should return a table cell when indexed" do
10
- table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
11
- table_row_object.should_receive(:[]).with(1).and_return(table_cell)
12
-
13
- table_row_object.should_receive(:size).and_return(3)
14
- table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
15
- table_row_object.should_receive(:wd).and_return(table_row_object)
16
-
17
- table_row[1].should be_instance_of Symbiont::WebObjects::TableCell
18
- end
19
-
20
- it "should return the number of columns" do
21
- table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
22
- table_row_object.stub(:wd).and_return(table_row_object)
23
- table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
24
- table_row_object.should_receive(:size).and_return(3)
25
- table_row.columns.should == 3
26
- end
27
-
28
- it "should iterate over the table columns" do
29
- table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
30
- table_row.should_receive(:columns).and_return(2)
31
- table_row.stub(:[]).and_return(table_row_object)
32
- count = 0
33
- table_row.each { |e| count += 1 }
34
- count.should == 2
35
- end
36
-
37
- #it "should return a row using text from the first row" do
38
- #table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
39
- #table_row_object.should_receive(:[]).with("column_text").and_return(table_row_object)
40
- #table_row_object.should_receive(:[]).with(0).and_return(table_row_object)
41
- #table_row_object.should_receive(:tag_name)
42
- #table_row_object.should_receive(:parent).and_return(table_row_object)
43
- #table_row_object.should_receive(:cells).and_return(table_row_object)
44
- #table_row_object.should_receive(:find_index).and_return("column_text")
45
-
46
- #table_row_object.should_receive(:size).and_return(1)
47
- #table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
48
- #table_row_object.should_receive(:wd).and_return(table_row_object)
49
-
50
- #table_row[1]["column_text"].should be_instance_of Symbiont::WebObjects::TableCell
51
- #end
52
-
53
- it "should register with a table row tag" do
54
- ::Symbiont::WebObjects.get_class_for(:tr).should == ::Symbiont::WebObjects::TableRow
55
- end
56
- end
57
- end
58
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::WebObjects::TableRow do
4
+ describe "implementation" do
5
+ let(:table_cell) { double('table_cell') }
6
+ let(:table_row_object) { double('table_row_object') }
7
+
8
+ context "on the watir platform" do
9
+ it "should return a table cell when indexed" do
10
+ table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
11
+ table_row_object.should_receive(:[]).with(1).and_return(table_cell)
12
+
13
+ table_row_object.should_receive(:size).and_return(3)
14
+ table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
15
+ table_row_object.should_receive(:wd).and_return(table_row_object)
16
+
17
+ table_row[1].should be_instance_of Symbiont::WebObjects::TableCell
18
+ end
19
+
20
+ it "should return the number of columns" do
21
+ table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
22
+ table_row_object.stub(:wd).and_return(table_row_object)
23
+ table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
24
+ table_row_object.should_receive(:size).and_return(3)
25
+ table_row.columns.should == 3
26
+ end
27
+
28
+ it "should iterate over the table columns" do
29
+ table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
30
+ table_row.should_receive(:columns).and_return(2)
31
+ table_row.stub(:[]).and_return(table_row_object)
32
+ count = 0
33
+ table_row.each { |e| count += 1 }
34
+ count.should == 2
35
+ end
36
+
37
+ #it "should return a row using text from the first row" do
38
+ #table_row = Symbiont::WebObjects::TableRow.new(table_row_object)
39
+ #table_row_object.should_receive(:[]).with("column_text").and_return(table_row_object)
40
+ #table_row_object.should_receive(:[]).with(0).and_return(table_row_object)
41
+ #table_row_object.should_receive(:tag_name)
42
+ #table_row_object.should_receive(:parent).and_return(table_row_object)
43
+ #table_row_object.should_receive(:cells).and_return(table_row_object)
44
+ #table_row_object.should_receive(:find_index).and_return("column_text")
45
+
46
+ #table_row_object.should_receive(:size).and_return(1)
47
+ #table_row_object.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_object)
48
+ #table_row_object.should_receive(:wd).and_return(table_row_object)
49
+
50
+ #table_row[1]["column_text"].should be_instance_of Symbiont::WebObjects::TableCell
51
+ #end
52
+
53
+ it "should register with a table row tag" do
54
+ ::Symbiont::WebObjects.get_class_for(:tr).should == ::Symbiont::WebObjects::TableRow
55
+ end
56
+ end
57
+ end
58
+ end