symbiont 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05110d9c5eeb8d6971262bff19bad09cc4ed6086
4
+ data.tar.gz: 589f9bbbf1eb5d49a919486bf7a31b89b952d4ab
5
+ SHA512:
6
+ metadata.gz: 298a058116b50448144fd72a1101951ffbe85fd6b57a246de08be66aad13b309905a0f61552632a24a2f20b476c5dc40ca933fc88fd75d217fe7420a719c82d1
7
+ data.tar.gz: ef93ec40a82704bd0e00b3e8d85c566ba725f2e8ce39db1d1670903c9abf8387e6f4cacadd25cea103c556f82b4a7f2a6e4d6b2bb92b12c5e9fe05c656dca9a5
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: 'travis-ci'
data/.gitignore CHANGED
@@ -1,22 +1,22 @@
1
- *.db
2
- *.gem
3
- *.rbc
4
- *.swo
5
- *.swp
6
- .idea
7
- .bundle
8
- .config
9
- .yardoc
10
- .DS_Store
11
- InstalledFiles
12
- _yardoc
13
- coverage
14
- output/
15
- doc/
16
- lib/bundler/man
17
- pkg
18
- rdoc
19
- spec/reports
20
- test/tmp
21
- test/version_tmp
22
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml CHANGED
@@ -1,14 +1,25 @@
1
- script: "rake"
2
-
3
- rvm:
4
- - 1.9.2
5
- - 1.9.3
6
-
7
- branches:
8
- only:
9
- - master
10
- - develop
11
-
12
- notifications:
13
- recipients:
14
- - jeffnyman@gmail.com
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.1
7
+ - jruby-19mode
8
+
9
+ branches:
10
+ except:
11
+ - experimental
12
+
13
+ branches:
14
+ only:
15
+ - master
16
+ - develop
17
+
18
+ notifications:
19
+ recipients:
20
+ - jeffnyman@gmail.com
21
+
22
+ matrix:
23
+ fast_finish: true
24
+ allow_failures:
25
+ - rvm: jruby-19mode
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'simplecov', '~> 0.8.0'
4
+ gem 'coveralls', require: false
2
5
 
3
- # Specify your gem's dependencies in symbiont.gemspec
4
6
  gemspec
@@ -1,22 +1,22 @@
1
- (The MIT License)
2
-
3
- Copyright © 2012 Jeff Nyman
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 Jeff Nyman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,65 +1,57 @@
1
- Symbiont [![Build Status](https://secure.travis-ci.org/jnyman/symbiont.png)](http://travis-ci.org/jnyman/symbiont) [![Dependency Status](https://gemnasium.com/jnyman/symbiont.png)](https://gemnasium.com/jnyman/symbiont)
2
- ========
3
-
4
- Description
5
- -----------
6
-
7
- The Symbiont gem is designed to provide an open framework for running automated tests against a browser using popular web testing interfaces.
8
-
9
- Right now the best information on the purpose of this project and how it works can be found on [my Symbiont-tagged blog posts](http://testerstories.com/?cat=16).
10
-
11
-
12
- Installation
13
- ------------
14
-
15
- Add this line to your application's Gemfile:
16
-
17
- gem 'symbiont'
18
-
19
- And then execute:
20
-
21
- $ bundle
22
-
23
- Or install it yourself as:
24
-
25
- $ gem install symbiont
26
-
27
-
28
- Using Symbiont
29
- --------------
30
-
31
- Check out the [Symbiont Wiki](https://github.com/jnyman/symbiont/wiki) for details on how to use Symbiont.
32
-
33
-
34
- Why call it Symbiont?
35
- ---------------------
36
-
37
- A "symbiont" is an organism in a symbiotic (mutually beneficial) relationship. Some of these relationships are called _obligate_, which means that both organisms need each other in order to survive. Other such relationships are called _facultative_, meaning that both organisms don't strictly need each other to survive, but they stand a better chance if they do.
38
-
39
- Symbiotic relationships include associations in which one organism lives on another organism -- _ectosymbiosis_ -- or where one organism lives inside the other -- _endosymbiosis_.
40
-
41
- So, with that bit of context, think of this gem as a facultative, endosymbiotic organism that lives within your test logic, giving it strength and sustenance.
42
-
43
-
44
- Contributing
45
- ------------
46
-
47
- 1. Fork it
48
- 2. Create your feature branch (`git checkout -b my-new-feature`)
49
- 3. Commit your changes (`git commit -am 'Added some feature'`)
50
- 4. Push to the branch (`git push origin my-new-feature`)
51
- 5. Create new Pull Request
52
-
53
-
54
- Credits
55
- -------
56
-
57
- Thanks to Jeff Morgan (http://www.cheezyworld.com/) for his page-object gem, Alister Scott (http://watirmelon.com) for his watir-page-helper gem, and Nat Ritmeyer (http://www.natontesting.com/) for his SitePrism gem. I learned a lot from analyzing their code and working to craft my own solution around theirs. Rather than fork their projects, my changes were systemic enough to warrant creating a new project.
58
-
59
-
60
- Copyright
61
- ---------
62
-
63
- See the LICENSE file for details.
64
-
65
- In short, Lucid is under an MIT license. Since I'm borrowing from many other people, just as they borrowed from many other people before them, I'm just establishing I wrote _this_ particular version. (If nothing else, this means you know who to blame.)
1
+ # Symbiont
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/symbiont.svg)](http://badge.fury.io/rb/symbiont)
4
+ [![Build Status](https://secure.travis-ci.org/jnyman/symbiont.png)](http://travis-ci.org/jnyman/symbiont)
5
+ [![Coverage Status](https://coveralls.io/repos/jnyman/symbiont/badge.png?branch=master)](https://coveralls.io/r/jnyman/symbiont?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/jnyman/symbiont.png)](https://codeclimate.com/github/jnyman/symbiont)
7
+ [![Dependency Status](https://gemnasium.com/jnyman/symbiont.png)](https://gemnasium.com/jnyman/symbiont)
8
+
9
+ Symbiont provides a semantic domain-specific language that can be used to construct a fluent interface for test execution libraries. The initial focus will be on using the [watir-webdriver](https://github.com/watir/watir-webdriver) API as the underlying driver library.
10
+
11
+ [![Gitter chat](https://badges.gitter.im/jnyman/symbiont.png)](https://gitter.im/jnyman/symbiont)
12
+ [![endorse](https://api.coderwall.com/jnyman/endorsecount.png)](https://coderwall.com/jnyman)
13
+
14
+
15
+ ## Installation
16
+
17
+ You can use Symbiont as part of another project, in which case you can add the following to your Gemfile:
18
+
19
+ gem 'symbiont'
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ You can also install Symbiont just as you would any other gem:
26
+
27
+ $ gem install symbiont
28
+
29
+ ## Usage
30
+
31
+ Instructions on how to use Symbiont will be available as the interface is defined. You can check out the [Symbiont test script](https://github.com/jnyman/symbiont/blob/master/test/symbiont-script.rb) for an idea of how the library can be interacted with. Do note that the test script requires a local copy of [Dialogic](https://github.com/jnyman/dialogic) to be running. To execute the test script:
32
+
33
+ $ rake test:script
34
+
35
+ ## Why call it Symbiont?
36
+
37
+ A "symbiont" is an organism in a symbiotic (mutually beneficial) relationship. Some of these relationships are called _obligate_, which means that both organisms need each other in order to survive. Other such relationships are called _facultative_, meaning that both organisms don't strictly need each other to survive, but they stand a better chance if they do.
38
+
39
+ Symbiotic relationships include associations in which one organism lives on another organism -- _ectosymbiosis_ -- or where one organism lives inside the other -- _endosymbiosis_.
40
+
41
+ So, with that bit of context, think of this library as a facultative, endosymbiotic organism that lives within your test logic, giving it strength and sustenance.
42
+
43
+ ## Contributing
44
+
45
+ 1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
46
+ 2. Create a feature branch. (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes. (`git commit -am 'new feature'`)
48
+ 4. Push the branch. (`git push origin my-new-feature`)
49
+ 5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
50
+
51
+ ## Credits
52
+
53
+ Thanks to Jeff Morgan ([http://www.cheezyworld.com/](http://www.cheezyworld.com/)) for his [page-object](https://github.com/cheezy/page-object) gem, Alister Scott ([http://watirmelon.com](http://watirmelon.com)) for his [watir-page-helper](https://github.com/alisterscott/watir-page-helper) gem, Alex Rodionov ([(http://p0deje.blogspot.com/](http://p0deje.blogspot.com/)) for his [watirsome](https://github.com/p0deje/watirsome) gem, and Nat Ritmeyer ([http://www.natritmeyer.com/](http://www.natritmeyer.com/)) for his [SitePrism](https://github.com/natritmeyer/site_prism/) gem.
54
+
55
+ ## Copyright
56
+
57
+ Symbiont is distributed under the MIT license. See the [LICENSE](https://github.com/jnyman/symbiont/blob/master/LICENSE.txt) file for details.
data/Rakefile CHANGED
@@ -1,34 +1,28 @@
1
- #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
- require 'cucumber/rake/task'
5
- require 'yard'
6
-
7
- RSpec::Core::RakeTask.new do |c|
8
- options = ["--color"]
9
- options += ["--format", "documentation"]
10
- options += ["--format", "nested", "--out output/rspec-report.txt"]
11
- options += ["--format", "html", "--out output/rspec-report.html"]
12
- c.rspec_opts = options
13
- end
14
-
15
- desc "Generate API documentation"
16
- YARD::Rake::YardocTask.new do |t|
17
- t.files = ['lib/**/*.rb']
18
- t.options = ['--title', 'Symbiont']
19
- end
20
-
21
- namespace :spec do
22
- desc "Get code coverage for spec execution"
23
- RSpec::Core::RakeTask.new('cov') do |c|
24
- ENV['COVERAGE'] = "on"
25
- end
26
- end
27
-
28
- namespace :specs do
29
- Cucumber::Rake::Task.new(:watir, "Run Cucumber with Watir") do |config|
30
- config.profile = 'default'
31
- end
32
- end
33
-
34
- task :default => :spec
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ namespace :test do
6
+ desc 'Run the Symbiont script.'
7
+ task :script do
8
+ system('ruby ./test/symbiont-script.rb')
9
+ end
10
+ end
11
+
12
+ namespace :spec do
13
+ desc 'Clean all generated reports'
14
+ task :clean do
15
+ system('rm -rf spec/reports')
16
+ end
17
+
18
+ RSpec::Core::RakeTask.new(:all => :clean) do |config|
19
+ options = %w(--color)
20
+ options += %w(--format documentation)
21
+ options += %w(--format html --out spec/reports/symbiont-test-report.html)
22
+ options += %w(--format nested --out spec/reports/symbiont-test-report.txt)
23
+
24
+ config.rspec_opts = options
25
+ end
26
+ end
27
+
28
+ task default: %w(spec:all)
@@ -0,0 +1,7 @@
1
+ module Symbiont
2
+ module Accessor
3
+ def reference_element(element, locator)
4
+ driver.send(element, locator)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ module Symbiont
2
+ module Assertion
3
+ include Helpers
4
+
5
+ def url_is(url=nil)
6
+ url_is_empty if url.nil? or url.empty?
7
+ @url = url
8
+ end
9
+
10
+ def url_matches(pattern=nil)
11
+ url_match_is_empty if pattern.nil?
12
+ url_match_is_empty if pattern.is_a?(String) and pattern.empty?
13
+ @url_match = pattern
14
+ end
15
+
16
+ def title_is(title=nil)
17
+ title_is_empty if title.nil? or title.empty?
18
+ @title = title
19
+ end
20
+
21
+ def url
22
+ @url
23
+ end
24
+
25
+ def url_match
26
+ @url_match
27
+ end
28
+
29
+ def page_title
30
+ @title
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,69 @@
1
+ module Symbiont
2
+ # Calls the Watir module to get a list of the factory methods that
3
+ # Watir uses to reference and access web objects.
4
+ #
5
+ # @return [Array] factory method list
6
+ def self.elements
7
+ unless @elements
8
+ @elements = Watir::Container.instance_methods
9
+ end
10
+ @elements
11
+ end
12
+
13
+ module Element
14
+ # Iterates through Watir factory methods. Each method is defined
15
+ # as a method that can be called on a page class. This is what
16
+ # allows element definitions to be created.
17
+ Symbiont.elements.each do |element|
18
+ define_method element do |*signature, &block|
19
+ identifier, locator = parse_signature(signature)
20
+ context = context_from_signature(locator, &block)
21
+ define_element_accessor(identifier, locator, element, &context)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ # @param identifier [String] friendly name of element definition
28
+ # @param locator [Array] locators for referencing the element
29
+ # @param element [String] name of Watir-based object
30
+ # @param block [Proc] a context block
31
+ #
32
+ # @example
33
+ # enable, {:id => 'enableForm'}, checkbox
34
+ def define_element_accessor(identifier, locator, element, &block)
35
+ define_method "#{identifier}".to_sym do |*values|
36
+ #puts "*** *values: #{values}"
37
+
38
+ if block_given?
39
+ instance_exec(*values, &block)
40
+ else
41
+ reference_element(element, locator)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Returns the identifier and locator portions of an element definition.
47
+ #
48
+ # @param signature [Array] full element definition
49
+ # @return [String] identifier and locator portions
50
+ def parse_signature(signature)
51
+ return signature.shift, signature.shift
52
+ end
53
+
54
+ # Returns the block or proc that serves as a context for an element
55
+ # definition.
56
+ #
57
+ # @param locator [Array] locators from element definition
58
+ # @param block [Proc] a context block
59
+ def context_from_signature(*locator, &block)
60
+ if block_given?
61
+ block
62
+ else
63
+ context = locator.shift
64
+ context.is_a?(Proc) && locator.empty? ? context : nil
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,7 @@
1
+ module Symbiont
2
+ module Errors
3
+ class NoUrlForDefinition < StandardError; end
4
+ class NoUrlMatchForDefinition < StandardError; end
5
+ class NoTitleForDefinition < StandardError; end
6
+ end
7
+ end
@@ -1,46 +1,75 @@
1
- module Symbiont
2
- module Factory
3
-
4
- # Creates a definition context for actions.
5
- #
6
- # @param [Class] definition The name of a definition class
7
- # @param [optional] block Logic to execute within the context of the
8
- # definition
9
- # @return [Object] instance of the definition
10
- def on(definition, visit=false, &block)
11
- definition = get_object_for(definition) if definition.is_a? String
12
- @active = definition.new(@browser, visit)
13
- block.call @active if block
14
- @active
15
- end
16
-
17
- # Creates a definition context for actions and establishes the
18
- # context for display.
19
- #
20
- # @param [Class] definition The name of a definition class
21
- # @param [optional] block Logic to execute within the context of the
22
- # definition
23
- # @return [Object] instance of the definition
24
- def on_view(definition, &block)
25
- on(definition, true, &block)
26
- end
27
-
28
- def if_on(definition, &block)
29
- definition = get_object_for(definition) if definition.is_a? String
30
- return @active unless @active.class == definition
31
- on(definition, false, &block)
32
- end
33
-
34
- alias_method :during, :on
35
- alias_method :start_activity, :on_view
36
- alias_method :start_on, :on_view
37
-
38
- private
39
-
40
- def get_object_for(definition)
41
- definition.split('::').inject(Object) do |obj, name|
42
- obj.const_get(name)
43
- end
44
- end
45
- end # module: Factory
46
- end # module: Symbiont
1
+ module Symbiont
2
+ module Factory
3
+
4
+ # Creates a definition context for actions. If an existing context
5
+ # exists, that context will be re-used.
6
+ #
7
+ # @param definition [Class] the name of a definition class
8
+ # @param visit [Boolean] true if the context needs to be called into view
9
+ # @param block [Proc] logic to execute in the context of the definition
10
+ # @return [Object] instance of the definition
11
+ def on(definition, visit=false, &block)
12
+ if @active.kind_of?(definition)
13
+ block.call @active if block
14
+ return @active
15
+ end
16
+
17
+ if @context.kind_of?(definition)
18
+ block.call @context if block
19
+ return @context
20
+ end
21
+
22
+ @active = definition.new(@driver)
23
+ @active.view if visit == true
24
+ block.call @active if block
25
+
26
+ @active
27
+ end
28
+
29
+ alias_method :on_page, :on
30
+ alias_method :while_on, :on
31
+
32
+ # Creates a definition context for actions and establishes the
33
+ # context for display.
34
+ #
35
+ # @param definition [Class] the name of a definition class
36
+ # @param block [Proc] logic to execute in the context of the definition
37
+ # @return [Object] instance of the definition
38
+ def on_view(definition, &block)
39
+ on(definition, true, &block)
40
+ end
41
+
42
+ alias_method :on_visit, :on_view
43
+
44
+ # Creates a definition context for actions. Unlike the on() factory,
45
+ # on_new will always create a new context and will never re-use an
46
+ # existing one.
47
+ #
48
+ # @param definition [Class] the name of a definition class
49
+ # @param block [Proc] logic to execute in the context of the definition
50
+ # @return [Object] instance of the definition
51
+ def on_new(definition, &block)
52
+ @active = nil
53
+
54
+ if @context.kind_of?(definition)
55
+ @context = nil
56
+ end
57
+
58
+ on(definition, &block)
59
+ end
60
+
61
+ # Creates a definition context for actions. If an existing context
62
+ # exists, that context will be re-used. This also sets a context that
63
+ # will be used for that definition even if the active definition
64
+ # changes.
65
+ #
66
+ # @param definition [Class] the name of a definition class
67
+ # @param block [Proc] logic to execute within the context of the definition
68
+ # @return [Object] instance of the definition
69
+ def on_set(definition, &block)
70
+ on(definition, &block)
71
+ @context = @active
72
+ @active
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,49 @@
1
+ module Symbiont
2
+ module Helpers
3
+ def url_is_empty
4
+ puts "\nERROR".on_red
5
+ puts "The url_is assertion is empty on the definition #{retrieve_class(caller)}.".cyan
6
+ raise Symbiont::Errors::NoUrlForDefinition
7
+ end
8
+
9
+ def url_match_is_empty
10
+ puts "\nERROR".on_red
11
+ puts "The url_matches assertion is empty on the definition #{retrieve_class(caller)}.".cyan
12
+ raise Symbiont::Errors::NoUrlMatchForDefinition
13
+ end
14
+
15
+ def title_is_empty
16
+ puts "\nERROR".on_red
17
+ puts "The title_is assertion is empty on the definition #{retrieve_class(caller)}.".cyan
18
+ raise Symbiont::Errors::NoTitleForDefinition
19
+ end
20
+
21
+ def no_url_is_provided
22
+ puts "\nERROR".on_red
23
+ puts "You called a '#{retrieve_method(caller)}' action but the definition #{self.class} does not have a url_is assertion.".cyan
24
+ raise Symbiont::Errors::NoUrlForDefinition
25
+ end
26
+
27
+ def no_url_matches_is_provided
28
+ puts "\nERROR".on_red
29
+ puts "You called a '#{retrieve_method(caller)}' action but the definition #{self.class} does not have a url_matches assertion.".cyan
30
+ raise Symbiont::Errors::NoUrlMatchForDefinition
31
+ end
32
+
33
+ def no_title_is_provided
34
+ puts "\nERROR".on_red
35
+ puts "You called a '#{retrieve_method(caller)}' action but the definition #{self.class} does not have a title_is assertion.".cyan
36
+ raise Symbiont::Errors::NoTitleForDefinition
37
+ end
38
+
39
+ private
40
+
41
+ def retrieve_class(caller)
42
+ caller[1][/`.*'/][8..-3]
43
+ end
44
+
45
+ def retrieve_method(caller)
46
+ caller[0][/`.*'/][1..-2]
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ module Symbiont
2
+ def self.trace(message, level = 1)
3
+ puts '*' * level + " #{message}" if ENV['SYMBIONT_TRACE'] == 'on'
4
+ end
5
+ end