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,32 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Symbiont::Generators do
4
- let(:watir_browser) { mock_browser_for_watir }
4
+ let(:watir_browser) { mock_browser_for_watir }
5
5
  let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
6
 
7
- describe "text field web objects" do
8
- context "when declared in a definition" do
7
+ describe "text field generators" do
8
+ context "when declared on a page definition" do
9
9
  it "should generate methods for referencing the text field" do
10
- watir_definition.should respond_to(:login_name_text_field)
11
- watir_definition.should respond_to(:login_name_object)
10
+ watir_definition.should respond_to(:name_text_field)
11
+ watir_definition.should respond_to(:name_object)
12
12
  end
13
13
 
14
- it "should generate methods for interacting with the link" do
15
- watir_definition.should respond_to(:login_name)
16
- watir_definition.should respond_to(:login_name_exists?)
17
- watir_definition.should respond_to(:login_name_visible?)
18
- watir_definition.should respond_to(:login_name_enabled?)
19
- watir_definition.should respond_to(:login_name?)
20
- watir_definition.should respond_to(:login_name_?)
21
- watir_definition.should respond_to(:login_name!)
22
- watir_definition.should respond_to(:login_name=)
14
+ it "should generate methods for interacting with the text field" do
15
+ watir_definition.should respond_to(:name)
16
+ watir_definition.should respond_to(:name_exists?)
17
+ watir_definition.should respond_to(:name_visible?)
18
+ watir_definition.should respond_to(:name_enabled?)
19
+ watir_definition.should respond_to(:name?)
20
+ watir_definition.should respond_to(:name_?)
21
+ watir_definition.should respond_to(:name!)
22
+ watir_definition.should respond_to(:name=)
23
23
  end
24
24
  end
25
25
 
26
26
  context "when used by the watir platform" do
27
27
  it "should locate the text field" do
28
28
  watir_browser.should_receive(:text_field).and_return(watir_browser)
29
- web_object = watir_definition.login_name_object
29
+ web_object = watir_definition.name_object
30
30
  web_object.should_not be_nil
31
31
  web_object.should be_instance_of Symbiont::WebObjects::TextField
32
32
  end
@@ -34,36 +34,39 @@ describe Symbiont::Generators do
34
34
  it "should retrieve text from the text field" do
35
35
  watir_browser.should_receive(:text_field).and_return(watir_browser)
36
36
  watir_browser.should_receive(:value).and_return("testing")
37
- watir_definition.login_name.should == "testing"
37
+ watir_definition.name.should == "testing"
38
38
  end
39
39
 
40
40
  it "should enter text into a text field" do
41
41
  watir_browser.should_receive(:text_field).and_return(watir_browser)
42
42
  watir_browser.should_receive(:set).with("testing")
43
- watir_definition.login_name = "testing"
43
+ watir_definition.name = "testing"
44
44
  end
45
45
 
46
46
  it "should determine if a text field exists" do
47
47
  watir_browser.should_receive(:text_field).twice.and_return(watir_browser)
48
48
  watir_browser.should_receive(:exists?).twice.and_return(watir_browser)
49
- watir_definition.login_name_exists?.should be_true
50
- watir_definition.login_name?.should be_true
49
+ watir_definition.name_exists?.should be_true
50
+ watir_definition.name?.should be_true
51
51
  end
52
-
52
+
53
53
  it "should determine if a text field is visible" do
54
54
  watir_browser.should_receive(:text_field).twice.and_return(watir_browser)
55
55
  watir_browser.should_receive(:present?).twice.and_return(watir_browser)
56
- watir_definition.login_name_visible?.should be_true
57
- watir_definition.login_name_?.should be_true
56
+ watir_definition.name_visible?.should be_true
57
+ watir_definition.name_?.should be_true
58
58
  end
59
-
59
+
60
60
  it "should determine if a text field is enabled" do
61
61
  watir_browser.should_receive(:text_field).twice.and_return(watir_browser)
62
62
  watir_browser.should_receive(:enabled?).twice.and_return(watir_browser)
63
- watir_definition.login_name_enabled?.should be_true
64
- watir_definition.login_name!.should be_true
63
+ watir_definition.name_enabled?.should be_true
64
+ watir_definition.name!.should be_true
65
65
  end
66
- end
67
66
 
67
+ it "should call a block on the element method if specified" do
68
+ watir_definition.email_object.should == "email"
69
+ end
70
+ end
68
71
  end
69
- end
72
+ end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Symbiont::Generators do
4
- let(:watir_browser) { mock_browser_for_watir }
4
+ let(:watir_browser) { mock_browser_for_watir }
5
5
  let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
6
 
7
7
  context "a definition using watir-webdriver" do
8
- describe "providing a url" do
8
+ context "providing a url" do
9
9
  it "should navigate to the page when viewed" do
10
10
  watir_browser.should_receive(:goto)
11
11
  watir_definition.view
@@ -16,34 +16,44 @@ describe Symbiont::Generators do
16
16
  watir_definition.start
17
17
  end
18
18
  end
19
-
20
- describe "providing a page title" do
21
- it "should specify and verify the page title" do
22
- watir_browser.should_receive(:title).and_return("Title of Page")
23
- watir_definition.should have_title
24
- end
25
-
26
- it "should raise an error if the page title is not verified" do
27
- watir_browser.should_receive(:title).twice.and_return("Incorrect Title")
28
- expect { watir_definition.has_title? }.to raise_error
29
- end
19
+ end
20
+
21
+ context "automatically looking for an object" do
22
+ it "should specify and verify an expected object" do
23
+ watir_definition.should_receive(:name_object).and_return(watir_browser)
24
+ watir_browser.should_receive(:when_actionable).with(5).and_return(watir_browser)
25
+ watir_definition.has_object?
30
26
  end
31
-
32
- describe "providing a page object" do
33
- it "should specify and verify an expected object" do
34
- watir_definition.should_receive(:testPage_object).and_return(watir_browser)
35
- watir_browser.should_receive(:when_actionable).with(5).and_return(watir_browser)
36
- watir_definition.has_object?
27
+
28
+ it "should raise an error if an expected object is not verified" do
29
+ class QuickDefinition
30
+ include Symbiont
31
+ look_for :fakeLink
37
32
  end
38
-
39
- it "should raise an error if the page object is not verified" do
40
- class QuickDefinition
41
- include Symbiont
42
- look_for :fakeLink
43
- end
44
- QuickDefinition.new(watir_browser).should_not have_object
33
+ expect { QuickDefinition.new(watir_browser).has_object? }.to raise_error
34
+ expect { QuickDefinition.new(watir_browser).should_not have_object }.to raise_error
35
+ end
36
+ end
37
+
38
+ context "providing a page title to be verified" do
39
+ it "should specify and verify the page title" do
40
+ watir_browser.should_receive(:title).and_return("Symbiote")
41
+ watir_definition.should have_title
42
+ end
43
+
44
+ it "should raise an error if the page title is not verified" do
45
+ watir_browser.should_receive(:title).twice.and_return("Incorrect Title")
46
+ expect { watir_definition.has_title? }.to raise_error
47
+ end
48
+
49
+ it "should validate the title if provided a regular expression" do
50
+ class QuickDefinition
51
+ include Symbiont
52
+ title_is (/\w+/)
45
53
  end
54
+ watir_browser.should_receive(:title).and_return("Symbiote")
55
+ QuickDefinition.new(watir_browser).should have_title
46
56
  end
47
-
48
57
  end
49
- end
58
+
59
+ end
@@ -1,68 +1,68 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::Locators do
4
- let(:watir_browser) { mock_browser_for_watir }
5
- let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
-
7
- context "a definition using watir-webdriver" do
8
- it "should locate a link web object" do
9
- watir_browser.should_receive(:link).with(text: 'test').and_return(watir_browser)
10
- web_object = watir_definition.link_object(text: 'test')
11
- web_object.should be_instance_of Symbiont::WebObjects::Link
12
- end
13
-
14
- it "should locate a button web object" do
15
- watir_browser.should_receive(:button).with(value: 'test').and_return(watir_browser)
16
- web_object = watir_definition.button_object(value: 'test')
17
- web_object.should be_instance_of Symbiont::WebObjects::Button
18
- end
19
-
20
- it "should locate a text field web object" do
21
- watir_browser.should_receive(:text_field).with(id: 'test').and_return(watir_browser)
22
- web_object = watir_definition.text_field_object(id: 'test')
23
- web_object.should be_instance_of Symbiont::WebObjects::TextField
24
- end
25
-
26
- it "should locate a select list web object" do
27
- watir_browser.should_receive(:select_list).with(class: 'test').and_return(watir_browser)
28
- web_object = watir_definition.select_list_object(class: 'test')
29
- web_object.should be_instance_of Symbiont::WebObjects::SelectList
30
- end
31
-
32
- it "should locate a checkbox web object" do
33
- watir_browser.should_receive(:checkbox).with(id: 'test').and_return(watir_browser)
34
- web_object = watir_definition.checkbox_object(id: 'test')
35
- web_object.should be_instance_of Symbiont::WebObjects::CheckBox
36
- end
37
-
38
- it "should locate a radio web object" do
39
- watir_browser.should_receive(:radio).with(id: 'test').and_return(watir_browser)
40
- web_object = watir_definition.radio_object(id: 'test')
41
- web_object.should be_instance_of Symbiont::WebObjects::Radio
42
- end
43
-
44
- it "should locate a div web object" do
45
- watir_browser.should_receive(:div).with(id: 'test').and_return(watir_browser)
46
- web_object = watir_definition.div_object(id: 'test')
47
- web_object.should be_instance_of Symbiont::WebObjects::Div
48
- end
49
-
50
- it "should locate a span object" do
51
- watir_browser.should_receive(:span).with(id: 'test').and_return(watir_browser)
52
- web_object = watir_definition.span_object(id: 'test')
53
- web_object.should be_instance_of Symbiont::WebObjects::Span
54
- end
55
-
56
- it "should locate a table web object" do
57
- watir_browser.should_receive(:table).with(id: 'test').and_return(watir_browser)
58
- web_object = watir_definition.table_object(id: 'test')
59
- web_object.should be_instance_of Symbiont::WebObjects::Table
60
- end
61
-
62
- it "should locate a table cell web object" do
63
- watir_browser.should_receive(:td).with(id: 'test').and_return(watir_browser)
64
- web_object = watir_definition.cell_object(id: 'test')
65
- web_object.should be_instance_of Symbiont::WebObjects::TableCell
66
- end
67
- end
68
- end
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::Locators do
4
+ let(:watir_browser) { mock_browser_for_watir }
5
+ let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
+
7
+ context "a definition using watir-webdriver" do
8
+ it "should locate a link web object" do
9
+ watir_browser.should_receive(:link).with(text: 'test').and_return(watir_browser)
10
+ web_object = watir_definition.link_object(text: 'test')
11
+ web_object.should be_instance_of Symbiont::WebObjects::Link
12
+ end
13
+
14
+ it "should locate a button web object" do
15
+ watir_browser.should_receive(:button).with(value: 'test').and_return(watir_browser)
16
+ web_object = watir_definition.button_object(value: 'test')
17
+ web_object.should be_instance_of Symbiont::WebObjects::Button
18
+ end
19
+
20
+ it "should locate a text field web object" do
21
+ watir_browser.should_receive(:text_field).with(id: 'test').and_return(watir_browser)
22
+ web_object = watir_definition.text_field_object(id: 'test')
23
+ web_object.should be_instance_of Symbiont::WebObjects::TextField
24
+ end
25
+
26
+ it "should locate a select list web object" do
27
+ watir_browser.should_receive(:select_list).with(class: 'test').and_return(watir_browser)
28
+ web_object = watir_definition.select_list_object(class: 'test')
29
+ web_object.should be_instance_of Symbiont::WebObjects::SelectList
30
+ end
31
+
32
+ it "should locate a checkbox web object" do
33
+ watir_browser.should_receive(:checkbox).with(id: 'test').and_return(watir_browser)
34
+ web_object = watir_definition.checkbox_object(id: 'test')
35
+ web_object.should be_instance_of Symbiont::WebObjects::CheckBox
36
+ end
37
+
38
+ it "should locate a radio web object" do
39
+ watir_browser.should_receive(:radio).with(id: 'test').and_return(watir_browser)
40
+ web_object = watir_definition.radio_object(id: 'test')
41
+ web_object.should be_instance_of Symbiont::WebObjects::Radio
42
+ end
43
+
44
+ it "should locate a div web object" do
45
+ watir_browser.should_receive(:div).with(id: 'test').and_return(watir_browser)
46
+ web_object = watir_definition.div_object(id: 'test')
47
+ web_object.should be_instance_of Symbiont::WebObjects::Div
48
+ end
49
+
50
+ it "should locate a span object" do
51
+ watir_browser.should_receive(:span).with(id: 'test').and_return(watir_browser)
52
+ web_object = watir_definition.span_object(id: 'test')
53
+ web_object.should be_instance_of Symbiont::WebObjects::Span
54
+ end
55
+
56
+ it "should locate a table web object" do
57
+ watir_browser.should_receive(:table).with(id: 'test').and_return(watir_browser)
58
+ web_object = watir_definition.table_object(id: 'test')
59
+ web_object.should be_instance_of Symbiont::WebObjects::Table
60
+ end
61
+
62
+ it "should locate a table cell web object" do
63
+ watir_browser.should_receive(:td).with(id: 'test').and_return(watir_browser)
64
+ web_object = watir_definition.cell_object(id: 'test')
65
+ web_object.should be_instance_of Symbiont::WebObjects::TableCell
66
+ end
67
+ end
68
+ end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Symbiont do
4
-
5
- let(:watir_browser) { mock_browser_for_watir }
4
+ let(:watir_browser) { mock_browser_for_watir }
6
5
  let(:watir_definition) { DefinitionTest.new(watir_browser) }
7
6
 
8
7
  context "a definition using watir-webdriver" do
@@ -16,5 +15,4 @@ describe Symbiont do
16
15
  expect { DefinitionTest.new(:unknown_browser) }.to raise_error
17
16
  end
18
17
  end
19
-
20
- end
18
+ end
@@ -5,23 +5,25 @@ describe Symbiont do
5
5
  Symbiont.version.should == "Symbiont v#{Symbiont::VERSION}"
6
6
  end
7
7
 
8
- it "should provide a page level wait default" do
9
- Symbiont.instance_variable_set("@page_wait", 10)
10
- Symbiont.page_level_wait.should == 10
11
- end
12
-
13
8
  it "should set the page level wait default to 15" do
14
9
  Symbiont.instance_variable_set("@page_wait", nil)
15
10
  Symbiont.page_level_wait.should == 15
16
11
  end
17
12
 
18
- it "should provide an element level wait default" do
19
- Symbiont.instance_variable_set("@element_wait", 5)
20
- Symbiont.element_level_wait.should == 5
13
+ it "should be able to set a page level wait value" do
14
+ Symbiont.page_level_wait = 30
15
+ value = Symbiont.instance_variable_get("@page_wait")
16
+ value.should == 30
21
17
  end
22
18
 
23
19
  it "should set the element level wait default to 5" do
24
20
  Symbiont.instance_variable_set("@element_wait", nil)
25
21
  Symbiont.element_level_wait.should == 5
26
22
  end
23
+
24
+ it "should be able to set an element level wait value" do
25
+ Symbiont.element_level_wait = 10
26
+ value = Symbiont.instance_variable_get("@element_wait")
27
+ value.should == 10
28
+ end
27
29
  end