symbiont 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +22 -22
  4. data/.travis.yml +25 -14
  5. data/Gemfile +4 -2
  6. data/{LICENSE → LICENSE.txt} +22 -22
  7. data/README.md +57 -65
  8. data/Rakefile +28 -34
  9. data/lib/symbiont/accessor.rb +7 -0
  10. data/lib/symbiont/assertions.rb +33 -0
  11. data/lib/symbiont/elements.rb +69 -0
  12. data/lib/symbiont/errors.rb +7 -0
  13. data/lib/symbiont/factory.rb +75 -46
  14. data/lib/symbiont/helpers.rb +49 -0
  15. data/lib/symbiont/logging.rb +5 -0
  16. data/lib/symbiont/pages.rb +32 -0
  17. data/lib/symbiont/platform.rb +12 -0
  18. data/lib/symbiont/version.rb +3 -3
  19. data/lib/symbiont.rb +34 -92
  20. data/spec/fixtures/element_definitions.rb +32 -0
  21. data/spec/fixtures/mock_drivers.rb +8 -0
  22. data/spec/fixtures/page_definitions.rb +36 -0
  23. data/spec/spec_helper.rb +31 -80
  24. data/spec/symbiont/assertion_spec.rb +88 -0
  25. data/spec/symbiont/driver_spec.rb +41 -0
  26. data/spec/symbiont/element_spec.rb +8 -0
  27. data/spec/symbiont/factory_spec.rb +70 -130
  28. data/spec/symbiont/page_spec.rb +50 -0
  29. data/symbiont.gemspec +52 -27
  30. data/test/symbiont-script.rb +97 -0
  31. metadata +89 -230
  32. data/Gemfile.lock +0 -44
  33. data/HISTORY.md +0 -99
  34. data/app/app.rb +0 -48
  35. data/app/public/css/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png +0 -0
  36. data/app/public/css/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png +0 -0
  37. data/app/public/css/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
  38. data/app/public/css/cupertino/images/ui-bg_glass_50_3baae3_1x400.png +0 -0
  39. data/app/public/css/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
  40. data/app/public/css/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png +0 -0
  41. data/app/public/css/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png +0 -0
  42. data/app/public/css/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png +0 -0
  43. data/app/public/css/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png +0 -0
  44. data/app/public/css/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  45. data/app/public/css/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  46. data/app/public/css/cupertino/images/ui-icons_3d80b3_256x240.png +0 -0
  47. data/app/public/css/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  48. data/app/public/css/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  49. data/app/public/css/cupertino/jquery-ui-1.8.16.custom.css +0 -290
  50. data/app/public/css/demo_table_jui.css +0 -471
  51. data/app/public/css/font/ColabLig-webfont.eot +0 -0
  52. data/app/public/css/font/ColabLig-webfont.svg +0 -149
  53. data/app/public/css/font/ColabLig-webfont.ttf +0 -0
  54. data/app/public/css/font/ColabLig-webfont.woff +0 -0
  55. data/app/public/css/font/ColabMed-webfont.eot +0 -0
  56. data/app/public/css/font/ColabMed-webfont.svg +0 -149
  57. data/app/public/css/font/ColabMed-webfont.ttf +0 -0
  58. data/app/public/css/font/ColabMed-webfont.woff +0 -0
  59. data/app/public/css/font/ColabReg-webfont.eot +0 -0
  60. data/app/public/css/font/ColabReg-webfont.svg +0 -149
  61. data/app/public/css/font/ColabReg-webfont.ttf +0 -0
  62. data/app/public/css/font/ColabReg-webfont.woff +0 -0
  63. data/app/public/css/font/ColabThi-webfont.eot +0 -0
  64. data/app/public/css/font/ColabThi-webfont.svg +0 -149
  65. data/app/public/css/font/ColabThi-webfont.ttf +0 -0
  66. data/app/public/css/font/ColabThi-webfont.woff +0 -0
  67. data/app/public/css/normalize.css +0 -376
  68. data/app/public/css/site.css +0 -446
  69. data/app/public/fancybox/blank.gif +0 -0
  70. data/app/public/fancybox/fancy_close.png +0 -0
  71. data/app/public/fancybox/fancy_loading.png +0 -0
  72. data/app/public/fancybox/fancy_nav_left.png +0 -0
  73. data/app/public/fancybox/fancy_nav_right.png +0 -0
  74. data/app/public/fancybox/fancy_shadow_e.png +0 -0
  75. data/app/public/fancybox/fancy_shadow_n.png +0 -0
  76. data/app/public/fancybox/fancy_shadow_ne.png +0 -0
  77. data/app/public/fancybox/fancy_shadow_nw.png +0 -0
  78. data/app/public/fancybox/fancy_shadow_s.png +0 -0
  79. data/app/public/fancybox/fancy_shadow_se.png +0 -0
  80. data/app/public/fancybox/fancy_shadow_sw.png +0 -0
  81. data/app/public/fancybox/fancy_shadow_w.png +0 -0
  82. data/app/public/fancybox/fancy_title_left.png +0 -0
  83. data/app/public/fancybox/fancy_title_main.png +0 -0
  84. data/app/public/fancybox/fancy_title_over.png +0 -0
  85. data/app/public/fancybox/fancy_title_right.png +0 -0
  86. data/app/public/fancybox/fancybox-x.png +0 -0
  87. data/app/public/fancybox/fancybox-y.png +0 -0
  88. data/app/public/fancybox/fancybox.png +0 -0
  89. data/app/public/fancybox/jquery.fancybox-1.3.4.css +0 -359
  90. data/app/public/fancybox/jquery.fancybox-1.3.4.js +0 -1156
  91. data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +0 -1
  92. data/app/public/img/Sorting icons.psd +0 -0
  93. data/app/public/img/back_disabled.png +0 -0
  94. data/app/public/img/back_enabled.png +0 -0
  95. data/app/public/img/back_enabled_hover.png +0 -0
  96. data/app/public/img/close.png +0 -0
  97. data/app/public/img/favicon.ico +0 -0
  98. data/app/public/img/forward_disabled.png +0 -0
  99. data/app/public/img/forward_enabled.png +0 -0
  100. data/app/public/img/forward_enabled_hover.png +0 -0
  101. data/app/public/img/lucid-bg.png +0 -0
  102. data/app/public/img/lucid-ft.png +0 -0
  103. data/app/public/img/open.png +0 -0
  104. data/app/public/img/sort_asc.png +0 -0
  105. data/app/public/img/sort_asc_disabled.png +0 -0
  106. data/app/public/img/sort_both.png +0 -0
  107. data/app/public/img/sort_desc.png +0 -0
  108. data/app/public/img/sort_desc_disabled.png +0 -0
  109. data/app/public/js/comics.js +0 -11
  110. data/app/public/js/signup.js +0 -141
  111. data/app/public/js/site.js +0 -42
  112. data/app/public/js/stardate.js +0 -35
  113. data/app/public/js/vendor/html5shiv.js +0 -5
  114. data/app/public/js/vendor/jquery-1.8.3.min.js +0 -2
  115. data/app/public/js/vendor/jquery.dataTables.min.js +0 -151
  116. data/app/public/js/vendor/jquery.validate.min.js +0 -4
  117. data/app/views/comics.erb +0 -344
  118. data/app/views/index.erb +0 -7
  119. data/app/views/layout.erb +0 -72
  120. data/app/views/layout_small.erb +0 -21
  121. data/app/views/stardate.erb +0 -5
  122. data/app/views/stardate_calc.erb +0 -30
  123. data/app/views/webobject.erb +0 -147
  124. data/lib/symbiont/data_setter.rb +0 -53
  125. data/lib/symbiont/enclosers.rb +0 -118
  126. data/lib/symbiont/evaluators.rb +0 -92
  127. data/lib/symbiont/generators.rb +0 -331
  128. data/lib/symbiont/locators.rb +0 -43
  129. data/lib/symbiont/logger.rb +0 -5
  130. data/lib/symbiont/platform_watir/platform_object.rb +0 -466
  131. data/lib/symbiont/platform_watir.rb +0 -9
  132. data/lib/symbiont/platforms.rb +0 -23
  133. data/lib/symbiont/web_objects/_common.rb +0 -174
  134. data/lib/symbiont/web_objects/button.rb +0 -22
  135. data/lib/symbiont/web_objects/checkbox.rb +0 -31
  136. data/lib/symbiont/web_objects/div.rb +0 -15
  137. data/lib/symbiont/web_objects/heading.rb +0 -12
  138. data/lib/symbiont/web_objects/hidden_field.rb +0 -19
  139. data/lib/symbiont/web_objects/label.rb +0 -15
  140. data/lib/symbiont/web_objects/link.rb +0 -23
  141. data/lib/symbiont/web_objects/list_item.rb +0 -13
  142. data/lib/symbiont/web_objects/option.rb +0 -10
  143. data/lib/symbiont/web_objects/ordered_list.rb +0 -49
  144. data/lib/symbiont/web_objects/paragraph.rb +0 -11
  145. data/lib/symbiont/web_objects/radio.rb +0 -31
  146. data/lib/symbiont/web_objects/select_list.rb +0 -82
  147. data/lib/symbiont/web_objects/span.rb +0 -15
  148. data/lib/symbiont/web_objects/table.rb +0 -71
  149. data/lib/symbiont/web_objects/table_cell.rb +0 -24
  150. data/lib/symbiont/web_objects/table_row.rb +0 -59
  151. data/lib/symbiont/web_objects/text_area.rb +0 -26
  152. data/lib/symbiont/web_objects/text_field.rb +0 -31
  153. data/lib/symbiont/web_objects/unordered_list.rb +0 -49
  154. data/lib/symbiont/web_objects.rb +0 -22
  155. data/lucid.yml +0 -6
  156. data/spec/symbiont/data_setter_spec.rb +0 -65
  157. data/spec/symbiont/enclosers_spec.rb +0 -76
  158. data/spec/symbiont/evaluators_spec.rb +0 -95
  159. data/spec/symbiont/generators/button_generators_spec.rb +0 -72
  160. data/spec/symbiont/generators/checkbox_generators_spec.rb +0 -79
  161. data/spec/symbiont/generators/div_generators_spec.rb +0 -56
  162. data/spec/symbiont/generators/hidden_field_generators_spec.rb +0 -65
  163. data/spec/symbiont/generators/link_generators_spec.rb +0 -62
  164. data/spec/symbiont/generators/paragraph_generators_spec.rb +0 -57
  165. data/spec/symbiont/generators/radio_generators_spec.rb +0 -76
  166. data/spec/symbiont/generators/select_list_generators_spec.rb +0 -93
  167. data/spec/symbiont/generators/span_generators_spec.rb +0 -56
  168. data/spec/symbiont/generators/table_cell_generators_spec.rb +0 -56
  169. data/spec/symbiont/generators/table_generators_spec.rb +0 -56
  170. data/spec/symbiont/generators/text_area_generators_spec.rb +0 -72
  171. data/spec/symbiont/generators/text_field_generators_spec.rb +0 -72
  172. data/spec/symbiont/generators_spec.rb +0 -59
  173. data/spec/symbiont/locators_spec.rb +0 -68
  174. data/spec/symbiont/platform_object_spec.rb +0 -18
  175. data/spec/symbiont/symbiont_spec.rb +0 -29
  176. data/spec/symbiont/web_object_spec.rb +0 -194
  177. data/spec/symbiont/web_objects/button_spec.rb +0 -38
  178. data/spec/symbiont/web_objects/checkbox_spec.rb +0 -27
  179. data/spec/symbiont/web_objects/div_spec.rb +0 -18
  180. data/spec/symbiont/web_objects/heading_spec.rb +0 -22
  181. data/spec/symbiont/web_objects/hidden_field_spec.rb +0 -18
  182. data/spec/symbiont/web_objects/label_spec.rb +0 -18
  183. data/spec/symbiont/web_objects/link_spec.rb +0 -33
  184. data/spec/symbiont/web_objects/list_item_spec.rb +0 -18
  185. data/spec/symbiont/web_objects/option_spec.rb +0 -9
  186. data/spec/symbiont/web_objects/ordered_list_spec.rb +0 -53
  187. data/spec/symbiont/web_objects/paragraph_spec.rb +0 -18
  188. data/spec/symbiont/web_objects/radio_spec.rb +0 -27
  189. data/spec/symbiont/web_objects/select_list_spec.rb +0 -69
  190. data/spec/symbiont/web_objects/span_spec.rb +0 -18
  191. data/spec/symbiont/web_objects/table_cell_spec.rb +0 -19
  192. data/spec/symbiont/web_objects/table_row_spec.rb +0 -58
  193. data/spec/symbiont/web_objects/table_spec.rb +0 -61
  194. data/spec/symbiont/web_objects/text_area_spec.rb +0 -18
  195. data/spec/symbiont/web_objects/text_field_spec.rb +0 -39
  196. data/spec/symbiont/web_objects/unordered_list_spec.rb +0 -51
  197. data/specs/common/support/browser.rb +0 -25
  198. data/specs/common/support/env.rb +0 -6
  199. data/specs/common/support/events.rb +0 -15
  200. data/specs/enclosers.feature +0 -9
  201. data/specs/evaluators.feature +0 -26
  202. data/specs/pages/characters.rb +0 -22
  203. data/specs/pages/home.rb +0 -9
  204. data/specs/pages/stardate.rb +0 -23
  205. data/specs/pages/web_objects.rb +0 -77
  206. data/specs/select_list.feature +0 -53
  207. data/specs/steps/enclosers_steps.rb +0 -17
  208. data/specs/steps/evaluators_steps.rb +0 -44
  209. data/specs/steps/navigation_steps.rb +0 -14
  210. data/specs/steps/select_list_steps.rb +0 -94
  211. data/specs/steps/table_cell_steps.rb +0 -31
  212. data/specs/steps/table_steps.rb +0 -87
  213. data/specs/table.feature +0 -49
  214. data/specs/table_cell.feature +0 -27
@@ -1,174 +1,114 @@
1
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
2
 
38
3
  describe Symbiont::Factory do
39
4
  before(:each) do
40
5
  @factory = TestFactory.new
41
- @factory.browser = mock_browser_for_watir
6
+ @factory.driver = mock_browser_for_watir
42
7
  end
43
8
 
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
9
+ it 'will create a new definition and view it, using on_view' do
10
+ @factory.driver.should_receive(:goto)
11
+ @factory.on_view(ValidPage)
57
12
  end
58
13
 
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
14
+ it 'will create a new definition and view it, using on_view and a block' do
15
+ @factory.driver.should_receive(:goto)
16
+ @factory.on_view ValidPage do |page|
17
+ page.should be_instance_of ValidPage
67
18
  end
19
+ end
68
20
 
69
- @factory.during "AppModule::TestDefinitionInModule" do |page|
70
- page.should be_instance_of AppModule::TestDefinitionInModule
21
+ it 'will create a new definition, using on and a block with a parameter' do
22
+ @factory.driver.should_not_receive(:goto)
23
+ @factory.on ValidPage do |page|
24
+ page.should be_instance_of ValidPage
71
25
  end
72
26
  end
73
27
 
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
28
+ it 'will create a new definition, using on and a block without a parameter' do
29
+ @factory.driver.should_not_receive(:goto)
30
+ @factory.on ValidPage do
31
+ @factory.active.should be_instance_of ValidPage
78
32
  end
33
+ end
79
34
 
80
- @factory.on_view "DefinitionTest" do |page|
81
- page.should be_instance_of DefinitionTest
82
- end
35
+ it 'will use an existing object reference with on' do
36
+ @factory.driver.should_receive(:goto)
37
+ obj1 = @factory.on_view ValidPage
38
+ obj2 = @factory.on ValidPage
39
+ obj1.should == obj2
40
+ end
83
41
 
84
- @factory.on_view "AppModule::TestDefinitionInModule" do |page|
85
- page.should be_instance_of AppModule::TestDefinitionInModule
86
- end
42
+ it 'will not use an existing object reference with on_new' do
43
+ @factory.driver.should_receive(:goto)
44
+ obj1 = @factory.on_view ValidPage
45
+ obj2 = @factory.on_new ValidPage
46
+ obj1.should_not == obj2
87
47
  end
88
48
 
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
49
+ it 'will create a new definition, using on_set' do
50
+ @factory.driver.should_not_receive(:goto)
51
+ @factory.on_set ValidPage do |page|
52
+ page.should be_instance_of ValidPage
93
53
  end
54
+ end
94
55
 
95
- @factory.start_activity "DefinitionTest" do |page|
96
- page.should be_instance_of DefinitionTest
97
- end
56
+ it 'will set a reference to be used outside the factory' do
57
+ active = @factory.on ValidPage
58
+ current = @factory.instance_variable_get '@active'
59
+ current.should === active
60
+ end
98
61
 
99
- @factory.start_activity "AppModule::TestDefinitionInModule" do |page|
100
- page.should be_instance_of AppModule::TestDefinitionInModule
101
- end
62
+ it 'will use an existing object reference with on_set' do
63
+ @factory.driver.should_receive(:goto)
64
+ obj1 = @factory.on_view ValidPage
65
+ obj2 = @factory.on_set ValidPage
66
+ obj1.should == obj2
102
67
  end
103
68
 
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
69
+ it 'will use an existing context using on after using on_set' do
70
+ @factory.on_set ValidPage do |page|
71
+ @obj1 = page # obj1 is CONTEXT, ACTIVE
108
72
  end
109
73
 
110
- @factory.start_on "DefinitionTest" do |page|
111
- page.should be_instance_of DefinitionTest
74
+ @factory.on ValidPageNewContext do |page|
75
+ @obj2 = page # obj2 is ACTIVE
112
76
  end
113
77
 
114
- @factory.start_on "AppModule::TestDefinitionInModule" do |page|
115
- page.should be_instance_of AppModule::TestDefinitionInModule
78
+ @factory.on ValidPage do |page|
79
+ @obj3 = page # obj1 CONTEXT is still set
116
80
  end
117
- end
118
81
 
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
82
+ @obj1.should_not == @obj2
83
+ @obj1.should == @obj3
123
84
  end
124
85
 
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
86
+ it 'will use an existing context using on_new of a different class after using on_set' do
87
+ @factory.on_set ValidPage do |page|
88
+ @obj1 = page # obj1 is CONTEXT, ACTIVE
132
89
  end
133
- used.should be true
134
90
 
135
- used = false
136
- @factory.if_on("TestFactorySecond") do |page|
137
- page.should be_instance_of TestFactorySecond
138
- used = true
91
+ @factory.on_new ValidPageNewContext do |page|
92
+ @obj2 = page # ACTIVE nil, obj1 no longer ACTIVE, but is CONTEXT
139
93
  end
140
- used.should be true
141
94
 
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
95
+ @factory.on ValidPage do |page|
96
+ @obj3 = page # CONTEXT is set to obj1
147
97
  end
148
- used.should be true
149
- end
150
98
 
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
99
+ @obj1.should_not == @obj2
100
+ @obj1.should == @obj3
101
+ end
156
102
 
157
- @factory.if_on("TestFactoryThird") do |page|
158
- fail
103
+ it 'will clear existing context using on_new after using on_set' do
104
+ @factory.on_set ValidPage do |page|
105
+ @obj1 = page # obj1 is CONTEXT, ACTIVE
159
106
  end
160
107
 
161
- @factory.if_on("AppModule::TestDefinitionInModule") do |page|
162
- fail
108
+ @factory.on_new ValidPage do |page|
109
+ @obj2 = page # ACTIVE nil; since page is same, CONTEXT is nil
163
110
  end
164
- end
165
111
 
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
112
+ @obj1.should_not == @obj2
172
113
  end
173
-
174
- end
114
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::Page do
4
+ include_context :page
5
+
6
+ context 'a page definition being used - url' do
7
+ it 'will establish no default url' do
8
+ expect(empty_definition.url).to be_nil
9
+ end
10
+
11
+ it 'will establish a page url with the url_is assertion' do
12
+ expect(watir_definition).to respond_to :url
13
+ expect(watir_definition.url).to eq('http://localhost:9292')
14
+ end
15
+
16
+ it 'will not view a page if the url_is assertion has not been set' do
17
+ expect { empty_definition.view }.to raise_error Symbiont::Errors::NoUrlForDefinition
18
+ end
19
+ end
20
+
21
+ context 'a page definition being used - url match' do
22
+ it 'will establish no default url matcher' do
23
+ expect(empty_definition.url_match).to be_nil
24
+ end
25
+
26
+ it 'will establish a url matcher with the url_matches assertion' do
27
+ expect(watir_definition).to respond_to :url_match
28
+ expect(watir_definition.url_match).to eq(/:\d{4}/)
29
+ end
30
+
31
+ it 'will not verify a url if the url_matches assertion has not been set' do
32
+ expect { empty_definition.has_correct_url? }.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
33
+ end
34
+ end
35
+
36
+ context 'a page definition being used - title' do
37
+ it 'will establish no default title' do
38
+ expect(empty_definition.page_title).to be_nil
39
+ end
40
+
41
+ it 'will establish a page title with the title_is assertion' do
42
+ expect(watir_definition).to respond_to :page_title
43
+ expect(watir_definition.page_title).to eq('Dialogic')
44
+ end
45
+
46
+ it 'will not verify a title if the title_is assertion has not been set' do
47
+ expect { empty_definition.has_correct_title? }.to raise_error Symbiont::Errors::NoTitleForDefinition
48
+ end
49
+ end
50
+ end
data/symbiont.gemspec CHANGED
@@ -1,27 +1,52 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/symbiont/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.name = "symbiont"
6
- gem.version = Symbiont::VERSION
7
- gem.platform = Gem::Platform::RUBY
8
- gem.license = "MIT"
9
- gem.authors = ["Jeff Nyman"]
10
- gem.email = ["jeffnyman@gmail.com"]
11
- gem.homepage = "https://github.com/jnyman/symbiont"
12
- gem.summary = gem.description
13
- gem.description = "An endosymbiotic facultative library for web application testing."
14
-
15
- gem.add_runtime_dependency "watir-webdriver", ">= 0.6.2"
16
- gem.add_runtime_dependency "selenium-webdriver", ">= 2.31.0"
17
-
18
- gem.add_development_dependency "rspec"
19
- gem.add_development_dependency "simplecov"
20
-
21
- gem.required_ruby_version = '>= 1.9.2'
22
-
23
- gem.files = `git ls-files`.split("\n")
24
- gem.test_files = `git ls-files -- {test,spec,specs,features}/*`.split("\n")
25
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- gem.require_paths = ["lib"]
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'symbiont/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'symbiont'
8
+ spec.version = Symbiont::VERSION
9
+ spec.authors = ['Jeff Nyman']
10
+ spec.email = ['jeffnyman@gmail.com']
11
+ spec.summary = %q{An Endosymbiotic Facultative Semantically Clean Fluent Interface Test Framework}
12
+ spec.description = %q{
13
+ Symbiont is a framework that allows you to describe your application in
14
+ terms of activity and page definitions. Those definitions can then be
15
+ referenced by test libraries using the DSL that Symbiont provides. The
16
+ DSL allows web elements to be proxied to a driver library.
17
+
18
+ The DSL provides a fluent interface that can be used for constructing
19
+ test execution logic. This fluent interface promotes the idea of
20
+ compressibility of your test logic, allowing for more factoring, more
21
+ reuse, and less repetition.
22
+
23
+ You can use Symbiont directly as an automated test library or you can
24
+ use it with other tools such as RSpec, Cucumber, or my own Lucid tool.
25
+ }
26
+ spec.homepage = 'https://github.com/jnyman/symbiont'
27
+ spec.license = 'MIT'
28
+ spec.requirements << 'Watir-WebDriver, Colorize'
29
+
30
+ spec.files = `git ls-files -z`.split("\x0")
31
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
+ spec.test_files = spec.files.grep(%r{^(test|spec|specs|features)/})
33
+ spec.require_paths = %w(lib)
34
+
35
+ spec.required_ruby_version = '>= 1.9.3'
36
+ spec.required_rubygems_version = '>= 1.8.29'
37
+
38
+ spec.add_development_dependency 'bundler', '~> 1.6'
39
+ spec.add_development_dependency 'rake'
40
+ spec.add_development_dependency 'rspec', '>= 2.14'
41
+
42
+ spec.add_runtime_dependency 'colorize', '>= 0.7.2'
43
+ spec.add_runtime_dependency 'watir-webdriver', '>= 0.6.9'
44
+
45
+ spec.post_install_message = %{
46
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
47
+
48
+ Symbiont #{Symbiont::VERSION} has been installed.
49
+
50
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
51
+ }
52
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ $: << './lib'
3
+
4
+ require 'rspec'
5
+ include RSpec::Matchers
6
+
7
+ require 'watir-webdriver'
8
+
9
+ require 'symbiont'
10
+ include Symbiont::Factory
11
+
12
+ #========================================
13
+
14
+ class Dialogic
15
+ attach Symbiont
16
+
17
+ url_is 'http://localhost:9292'
18
+ end
19
+
20
+ class Weight
21
+ attach Symbiont
22
+
23
+ url_is 'http://localhost:9292/weight'
24
+
25
+ text_field :weight, id: 'wt', index: 0
26
+ button :calculate, id: 'calculate'
27
+
28
+ def convert(value)
29
+ weight.set value
30
+ end
31
+ end
32
+
33
+ class Practice
34
+ attach Symbiont
35
+
36
+ url_is 'http://localhost:9292/practice'
37
+ url_matches /:\d{4}/
38
+ title_is 'Dialogic - Practice Page'
39
+
40
+ link :view_in_frame, id: 'framed_page'
41
+
42
+ iframe :boxframe, class: 'fancybox-iframe'
43
+
44
+ text_field :weight, -> { boxframe.text_field(id: 'wt') }
45
+
46
+ article :practice, id: 'practice'
47
+
48
+ a :page_link do |text|
49
+ practice.a(text: text)
50
+ end
51
+ end
52
+
53
+ @driver = Watir::Browser.new
54
+
55
+ def non_framed
56
+ @page = Weight.new(@driver)
57
+ @page.view
58
+ @page.weight.set '200'
59
+ @page.calculate.click
60
+ end
61
+
62
+ def framed
63
+ @page = Practice.new(@driver)
64
+ @page.view
65
+ #@page.view_in_frame.click
66
+ @page.page_link('View Weight Calculator in Frame').click
67
+ @page.weight.set '200'
68
+ end
69
+
70
+ def basic
71
+ @page = Practice.new(@driver)
72
+ @page.should be_a_kind_of(Symbiont)
73
+ @page.should be_an_instance_of(Practice)
74
+
75
+ @page.view
76
+ @page.has_correct_url?
77
+ @page.has_correct_title?
78
+
79
+ @page.should have_correct_url
80
+ @page.should have_correct_title
81
+ end
82
+
83
+ #basic
84
+
85
+ on_view(Weight)
86
+ on(Weight).convert('200')
87
+ on(Weight).calculate.click
88
+
89
+ on(Weight) do
90
+ @active.convert('200')
91
+ @active.calculate.click
92
+ end
93
+
94
+ on(Weight) do |page|
95
+ page.convert('200')
96
+ page.calculate.click
97
+ end