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,75 +1,95 @@
1
- require 'spec_helper'
2
-
3
- describe Symbiont::Enclosers do
4
- let(:watir_browser) { mock_browser_for_watir }
5
- let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
-
7
- describe "browser-level actions" do
8
- context "a definition using watir-webdriver" do
9
- it "should visit a page" do
10
- watir_browser.should_receive(:goto).with("http://localhost:4567")
11
- watir_definition.visit("http://localhost:4567")
12
- end
13
-
14
- it "should get the active url" do
15
- watir_browser.should_receive(:url).and_return("http://localhost:4567")
16
- watir_definition.url.should == "http://localhost:4567"
17
- end
18
-
19
- it "should get a screenshot" do
20
- watir_browser.should_receive(:wd).and_return(watir_browser)
21
- watir_browser.should_receive(:save_screenshot)
22
- watir_definition.screenshot("testing.png")
23
- end
24
-
25
- it "should run a script against the browser" do
26
- watir_browser.should_receive(:execute_script).twice.and_return("input")
27
- watir_definition.run_script("return document.activeElement").should == "input"
28
- watir_definition.execute_script("return document.activeElement").should == "input"
29
- end
30
- end
31
- end
32
-
33
- describe "page-level actions" do
34
- context "a definition using watir-webdriver" do
35
- it "should return all the text on a page" do
36
- watir_browser.should_receive(:text).and_return("page text")
37
- watir_definition.text.should == "page text"
38
- end
39
-
40
- it "should return all the markup on a page" do
41
- watir_browser.should_receive(:html).twice.and_return("<h1>Page Title</h1>")
42
- watir_definition.markup.should == "<h1>Page Title</h1>"
43
- watir_definition.html.should == "<h1>Page Title</h1>"
44
- end
45
-
46
- it "should return the title of a page" do
47
- watir_browser.should_receive(:title).and_return("Page Title")
48
- watir_definition.title.should == "Page Title"
49
- end
50
-
51
- it "should return the web object that has focus" do
52
- watir_browser.should_receive(:execute_script).and_return(watir_browser)
53
- watir_browser.should_receive(:tag_name).twice.and_return(:input)
54
- watir_browser.should_receive(:type).and_return(:submit)
55
- watir_definition.focus.class.should == Symbiont::WebObjects::Button
56
- end
57
-
58
- it "should wait for jquery pending requests to finish" do
59
- watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(0)
60
- watir_definition.wait_for_pending_requests
61
- end
62
-
63
- it "should return an exception if pending requests did not finish" do
64
- watir_browser.should_receive(:execute_script).with('return jQuery.active')
65
- watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(1)
66
- expect { watir_definition.wait_for_pending_requests(1) }.to raise_error
67
- end
68
-
69
- it "should be able to go back to a previous page" do
70
- watir_browser.should_receive(:back)
71
- watir_definition.back
72
- end
73
- end
74
- end
75
- end
1
+ require "spec_helper"
2
+
3
+ describe Symbiont::Evaluators do
4
+ let(:watir_browser) { mock_browser_for_watir }
5
+ let(:watir_definition) { DefinitionTest.new(watir_browser) }
6
+
7
+ describe "browser-level actions" do
8
+ context "a definition using watir-webdriver" do
9
+ it "should visit a page" do
10
+ watir_browser.should_receive(:goto).twice.with("http://localhost:9292")
11
+ watir_definition.visit("http://localhost:9292")
12
+ watir_definition.navigate_to("http://localhost:9292")
13
+ end
14
+
15
+ it "should get the active url" do
16
+ watir_browser.should_receive(:url).twice.and_return("http://localhost:9292")
17
+ watir_definition.url.should == "http://localhost:9292"
18
+ watir_definition.current_url.should == "http://localhost:9292"
19
+ end
20
+
21
+ it "should get a screenshot" do
22
+ watir_browser.should_receive(:wd).twice.and_return(watir_browser)
23
+ watir_browser.should_receive(:save_screenshot).twice
24
+ watir_definition.screenshot("testing.png")
25
+ watir_definition.save_screenshot("testing.png")
26
+ end
27
+
28
+ it "should run a script against the browser" do
29
+ watir_browser.should_receive(:execute_script).twice.and_return("input")
30
+ watir_definition.run_script("return document.activeElement").should == "input"
31
+ watir_definition.execute_script("return document.activeElement").should == "input"
32
+ end
33
+
34
+ it "should be able to go back to a previous page" do
35
+ watir_browser.should_receive(:back)
36
+ watir_definition.back
37
+ end
38
+
39
+ it "should be able to go forward to an already visited page" do
40
+ watir_browser.should_receive(:forward)
41
+ watir_definition.forward
42
+ end
43
+
44
+ it "should be able to refresh the page contents" do
45
+ watir_browser.should_receive(:refresh)
46
+ watir_definition.refresh
47
+ end
48
+
49
+ it "should be able to clear all of the cookies from the browser" do
50
+ watir_browser.should_receive(:cookies).twice.and_return(watir_browser)
51
+ watir_browser.should_receive(:clear).twice
52
+ watir_definition.remove_cookies
53
+ watir_definition.clear_cookies
54
+ end
55
+ end
56
+ end
57
+
58
+ describe "page-level actions" do
59
+ context "a definition using watir-webdriver" do
60
+ it "should return all the text on a page" do
61
+ watir_browser.should_receive(:text).and_return("page text")
62
+ watir_definition.text.should == "page text"
63
+ end
64
+
65
+ it "should return all the markup on a page" do
66
+ watir_browser.should_receive(:html).twice.and_return("<h1>Page Title</h1>")
67
+ watir_definition.markup.should == "<h1>Page Title</h1>"
68
+ watir_definition.html.should == "<h1>Page Title</h1>"
69
+ end
70
+
71
+ it "should return the title of a page" do
72
+ watir_browser.should_receive(:title).and_return("Page Title")
73
+ watir_definition.title.should == "Page Title"
74
+ end
75
+
76
+ it "should return the web object that has focus" do
77
+ watir_browser.should_receive(:execute_script).and_return(watir_browser)
78
+ watir_browser.should_receive(:tag_name).twice.and_return(:input)
79
+ watir_browser.should_receive(:type).and_return(:submit)
80
+ watir_definition.focus.class.should == Symbiont::WebObjects::Button
81
+ end
82
+
83
+ it "should wait for jquery pending requests to finish" do
84
+ watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(0)
85
+ watir_definition.wait_for_pending_requests
86
+ end
87
+
88
+ it "should return an exception if pending requests did not finish" do
89
+ watir_browser.should_receive(:execute_script).with('return jQuery.active')
90
+ watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(1)
91
+ expect { watir_definition.wait_for_pending_requests(1) }.to raise_error
92
+ end
93
+ end
94
+ end
95
+ end
@@ -1,122 +1,174 @@
1
- require 'spec_helper'
2
- require 'symbiont/factory'
3
-
4
- class TestFactory
5
- include Symbiont::Factory
6
-
7
- attr_accessor :browser
8
- attr_accessor :active
9
- end
10
-
11
- class TestFactorySecond
12
- include Symbiont
13
- end
14
-
15
- class TestFactoryThird
16
- include Symbiont
17
- end
18
-
19
- describe Symbiont::Factory do
20
- #let(:watir_browser) { mock_browser_for_watir }
21
- #let(:factory) { TestFactory.new(watir_browser) }
22
-
23
- before(:each) do
24
- @factory = TestFactory.new
25
- @factory.browser = mock_browser_for_watir
26
- end
27
-
28
- it "should create a new definition object, using on" do
29
- @factory.on DefinitionTest do |page|
30
- page.should be_instance_of DefinitionTest
31
- end
32
- end
33
-
34
- it "should create a new definition object, using during" do
35
- @factory.during DefinitionTest do |page|
36
- page.should be_instance_of DefinitionTest
37
- end
38
- end
39
-
40
- it "should create a new definition object and view it, using on_view" do
41
- @factory.browser.should_receive(:goto).twice
42
- @factory.on_view DefinitionTest do |page|
43
- page.should be_instance_of DefinitionTest
44
- end
45
- end
46
-
47
- it "should create a new definition object and view it, using start_activity" do
48
- @factory.browser.should_receive(:goto).twice
49
- @factory.start_activity DefinitionTest do |page|
50
- page.should be_instance_of DefinitionTest
51
- end
52
- end
53
-
54
- it "should set a reference to be used outside the factory" do
55
- active = @factory.on DefinitionTest
56
- current = @factory.instance_variable_get "@active"
57
- current.should === active
58
- end
59
-
60
- it "should use an existing definition when that definition is already active" do
61
- @factory.instance_variable_set "@active", TestFactorySecond.new(@factory.browser)
62
- @factory.on(TestFactorySecond) do |page|
63
- page.should be_instance_of TestFactorySecond
64
- end
65
- end
66
-
67
- it "should not execute block if definition is not the active definition" do
68
- @factory.instance_variable_set "@active", TestFactorySecond.new(@factory.browser)
69
- @factory.on(TestFactoryThird) do |page|
70
- page.should_not be_instance_of TestFactorySecond
71
- page.should be_instance_of TestFactoryThird
72
- end
73
- end
74
-
75
- it "should store a workflow path" do
76
- workflow = ['stage1', 'stage2', 'stage3']
77
- Symbiont::Factory.workflow = {default: workflow}
78
- Symbiont::Factory.symbiont_workflow[:default].should == workflow
79
- end
80
-
81
- it "should be unable to work without a default worfklow path" do
82
- expect { Symbiont::Factory.workflow = {another: []} }.to raise_error
83
- end
84
-
85
- it "should start a workflow path by using the default path" do
86
- paths = [[TestFactory, :first_action], [TestFactorySecond, :second_action]]
87
- Symbiont::Factory.workflow = {:default => paths}
88
- mock_page = double("mock_page")
89
- TestFactory.should_receive(:new).and_return(mock_page)
90
- mock_page.should_receive(:first_action)
91
- @factory.start_workflow(TestFactorySecond).class.should == TestFactorySecond
92
- end
93
-
94
- it "should not start a workflow when there is no proper path" do
95
- Symbiont::Factory.workflow = {:default => ['default'], :standard => ['standard']}
96
- expect { @factory.start_workflow(TestFactory, :using => :invalid_path) }.to raise_error
97
- end
98
-
99
- it "should not use a workflow when an action is not specified" do
100
- Symbiont::Factory.workflow = {:default => [[TestFactory, :action_1], [TestFactorySecond, :action_2]]}
101
- mock_page = double("mock_page")
102
- TestFactory.should_receive(:new).and_return(mock_page)
103
- mock_page.should_receive(:respond_to?).with(:action_1).and_return(false)
104
- expect { @factory.start_workflow(TestFactorySecond) }.to raise_error
105
- end
106
-
107
- it "should be able to continue along a workflow" do
108
- Symbiont::Factory.workflow = {
109
- :default => [[TestFactory, :action_1],
110
- [TestFactorySecond, :action_2],
111
- [TestFactoryThird, :action_3]]
112
- }
113
- mock_page = double("mock_page")
114
- TestFactorySecond.should_receive(:new).and_return(mock_page)
115
- mock_page.should_receive(:respond_to?).with(:action_2).and_return(true)
116
- mock_page.should_receive(:action_2)
117
- @factory.active = TestFactory.new()
118
- TestFactory.should_not_receive(:new)
119
- @factory.continue_workflow(TestFactoryThird).class.should == TestFactoryThird
120
- end
121
-
122
- end
1
+ require 'spec_helper'
2
+ require 'symbiont/factory'
3
+
4
+ module AppModule
5
+ class TestDefinitionInModule
6
+ include Symbiont
7
+ url_is "http://localhost:9292"
8
+ end
9
+ end
10
+
11
+ class TestFactory
12
+ include Symbiont::Factory
13
+
14
+ attr_accessor :browser
15
+ attr_accessor :active
16
+ end
17
+
18
+ class TestFactoryPage
19
+ include Symbiont
20
+
21
+ url_is "http://localhost:9292"
22
+ end
23
+
24
+ class TestFactoryWithURL
25
+ include Symbiont
26
+
27
+ url_is "http://localhost:9292"
28
+ end
29
+
30
+ class TestFactorySecond
31
+ include Symbiont
32
+ end
33
+
34
+ class TestFactoryThird
35
+ include Symbiont
36
+ end
37
+
38
+ describe Symbiont::Factory do
39
+ before(:each) do
40
+ @factory = TestFactory.new
41
+ @factory.browser = mock_browser_for_watir
42
+ end
43
+
44
+ it "should create a new definition object, using on" do
45
+ @factory.browser.should_not_receive(:goto)
46
+ @factory.on DefinitionTest do |page|
47
+ page.should be_instance_of DefinitionTest
48
+ end
49
+
50
+ @factory.on "DefinitionTest" do |page|
51
+ page.should be_instance_of DefinitionTest
52
+ end
53
+
54
+ @factory.on "AppModule::TestDefinitionInModule" do |page|
55
+ page.should be_instance_of AppModule::TestDefinitionInModule
56
+ end
57
+ end
58
+
59
+ it "should create a new definition object, using during" do
60
+ @factory.browser.should_not_receive(:goto)
61
+ @factory.during DefinitionTest do |page|
62
+ page.should be_instance_of DefinitionTest
63
+ end
64
+
65
+ @factory.during "DefinitionTest" do |page|
66
+ page.should be_instance_of DefinitionTest
67
+ end
68
+
69
+ @factory.during "AppModule::TestDefinitionInModule" do |page|
70
+ page.should be_instance_of AppModule::TestDefinitionInModule
71
+ end
72
+ end
73
+
74
+ it "should create a new definition object and view it, using on_view" do
75
+ @factory.browser.should_receive(:goto).exactly(5).times
76
+ @factory.on_view DefinitionTest do |page|
77
+ page.should be_instance_of DefinitionTest
78
+ end
79
+
80
+ @factory.on_view "DefinitionTest" do |page|
81
+ page.should be_instance_of DefinitionTest
82
+ end
83
+
84
+ @factory.on_view "AppModule::TestDefinitionInModule" do |page|
85
+ page.should be_instance_of AppModule::TestDefinitionInModule
86
+ end
87
+ end
88
+
89
+ it "should create a new definition object and view it, using start_activity" do
90
+ @factory.browser.should_receive(:goto).exactly(5).times
91
+ @factory.start_activity DefinitionTest do |page|
92
+ page.should be_instance_of DefinitionTest
93
+ end
94
+
95
+ @factory.start_activity "DefinitionTest" do |page|
96
+ page.should be_instance_of DefinitionTest
97
+ end
98
+
99
+ @factory.start_activity "AppModule::TestDefinitionInModule" do |page|
100
+ page.should be_instance_of AppModule::TestDefinitionInModule
101
+ end
102
+ end
103
+
104
+ it "should create a new definition object and view it, using start_on" do
105
+ @factory.browser.should_receive(:goto).exactly(5).times
106
+ @factory.start_on DefinitionTest do |page|
107
+ page.should be_instance_of DefinitionTest
108
+ end
109
+
110
+ @factory.start_on "DefinitionTest" do |page|
111
+ page.should be_instance_of DefinitionTest
112
+ end
113
+
114
+ @factory.start_on "AppModule::TestDefinitionInModule" do |page|
115
+ page.should be_instance_of AppModule::TestDefinitionInModule
116
+ end
117
+ end
118
+
119
+ it "should set a reference to be used outside the factory" do
120
+ active = @factory.on DefinitionTest
121
+ current = @factory.instance_variable_get "@active"
122
+ current.should === active
123
+ end
124
+
125
+ it "should use an existing definition when that definition is already active" do
126
+ @factory.instance_variable_set "@active", TestFactorySecond.new(@factory.browser)
127
+
128
+ used = false
129
+ @factory.if_on(TestFactorySecond) do |page|
130
+ page.should be_instance_of TestFactorySecond
131
+ used = true
132
+ end
133
+ used.should be true
134
+
135
+ used = false
136
+ @factory.if_on("TestFactorySecond") do |page|
137
+ page.should be_instance_of TestFactorySecond
138
+ used = true
139
+ end
140
+ used.should be true
141
+
142
+ used = false
143
+ @factory.instance_variable_set "@active", AppModule::TestDefinitionInModule.new(@factory.browser)
144
+ @factory.if_on("AppModule::TestDefinitionInModule") do |page|
145
+ page.should be_instance_of AppModule::TestDefinitionInModule
146
+ used = true
147
+ end
148
+ used.should be true
149
+ end
150
+
151
+ it "should not execute block if definition is not the active definition" do
152
+ @factory.instance_variable_set "@active", TestFactorySecond.new(@factory.browser)
153
+ @factory.if_on(TestFactoryThird) do |page|
154
+ fail
155
+ end
156
+
157
+ @factory.if_on("TestFactoryThird") do |page|
158
+ fail
159
+ end
160
+
161
+ @factory.if_on("AppModule::TestDefinitionInModule") do |page|
162
+ fail
163
+ end
164
+ end
165
+
166
+ it "should return the @active instance if asking for another page" do
167
+ expected = TestFactoryWithURL.new(@factory.browser)
168
+ @factory.instance_variable_set "@active", expected
169
+ @factory.if_on(TestFactoryPage).should == expected
170
+ @factory.if_on("TestFactoryPage").should == expected
171
+ @factory.if_on("AppModule::TestDefinitionInModule").should == expected
172
+ end
173
+
174
+ end
@@ -1,69 +1,72 @@
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 "button web objects" do
8
- context "when declared in a definition" do
7
+ describe "button generators" do
8
+ context "when declared on a page definition" do
9
9
  it "should generate methods for referencing the button" do
10
- watir_definition.should respond_to(:submit_object)
11
- watir_definition.should respond_to(:submit_button)
10
+ watir_definition.should respond_to(:login_object)
11
+ watir_definition.should respond_to(:login_button)
12
12
  end
13
13
 
14
- it "should generate methods for interacting with the link" do
15
- watir_definition.should respond_to(:submit)
16
- watir_definition.should respond_to(:submit_text)
17
- watir_definition.should respond_to(:submit_exists?)
18
- watir_definition.should respond_to(:submit_visible?)
19
- watir_definition.should respond_to(:submit_enabled?)
20
- watir_definition.should respond_to(:submit?)
21
- watir_definition.should respond_to(:submit_?)
22
- watir_definition.should respond_to(:submit!)
14
+ it "should generate methods for interacting with the button" do
15
+ watir_definition.should respond_to(:login)
16
+ watir_definition.should respond_to(:login_text)
17
+ watir_definition.should respond_to(:login_exists?)
18
+ watir_definition.should respond_to(:login_visible?)
19
+ watir_definition.should respond_to(:login_enabled?)
20
+ watir_definition.should respond_to(:login?)
21
+ watir_definition.should respond_to(:login_?)
22
+ watir_definition.should respond_to(:login!)
23
23
  end
24
24
  end
25
25
 
26
- context "used by the watir platform" do
26
+ context "when used by the watir platform" do
27
27
  it "should locate the button" do
28
28
  watir_browser.should_receive(:button).and_return(watir_browser)
29
- web_object = watir_definition.submit_object
29
+ web_object = watir_definition.login_object
30
30
  web_object.should_not be_nil
31
31
  web_object.should be_instance_of Symbiont::WebObjects::Button
32
32
  end
33
-
33
+
34
34
  it "should return the text of the button" do
35
35
  watir_browser.should_receive(:button).and_return(watir_browser)
36
- watir_browser.should_receive(:text).and_return('Submit')
37
- watir_definition.submit_text.should == "Submit"
36
+ watir_browser.should_receive(:text).and_return('Login')
37
+ watir_definition.login_text.should == "Login"
38
38
  end
39
-
39
+
40
40
  it "should click the button" do
41
41
  watir_browser.should_receive(:button).and_return(watir_browser)
42
42
  watir_browser.should_receive(:click)
43
- watir_definition.submit
43
+ watir_definition.login
44
44
  end
45
45
 
46
46
  it "should determine if a button exists" do
47
47
  watir_browser.should_receive(:button).twice.and_return(watir_browser)
48
48
  watir_browser.should_receive(:exists?).twice.and_return(watir_browser)
49
- watir_definition.submit?.should be_true
50
- watir_definition.submit_exists?.should be_true
49
+ watir_definition.login?.should be_true
50
+ watir_definition.login_exists?.should be_true
51
51
  end
52
-
52
+
53
53
  it "should determine if a button is visible" do
54
54
  watir_browser.should_receive(:button).twice.and_return(watir_browser)
55
55
  watir_browser.should_receive(:present?).twice.and_return(watir_browser)
56
- watir_definition.submit_?.should be_true
57
- watir_definition.submit_visible?.should be_true
56
+ watir_definition.login_?.should be_true
57
+ watir_definition.login_visible?.should be_true
58
58
  end
59
-
59
+
60
60
  it "should determine if a button is enabled" do
61
61
  watir_browser.should_receive(:button).twice.and_return(watir_browser)
62
62
  watir_browser.should_receive(:enabled?).twice.and_return(watir_browser)
63
- watir_definition.submit_enabled?.should be_true
64
- watir_definition.submit!.should be_true
63
+ watir_definition.login_enabled?.should be_true
64
+ watir_definition.login!.should be_true
65
65
  end
66
- end
67
66
 
67
+ it "should call a block on the button if specified" do
68
+ watir_definition.logout_object.should == "logout"
69
+ end
70
+ end
68
71
  end
69
- end
72
+ end