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
@@ -0,0 +1,32 @@
1
+ module Symbiont
2
+ module Page
3
+ include Helpers
4
+
5
+ def view
6
+ no_url_is_provided if url.nil?
7
+ driver.goto(url)
8
+ end
9
+
10
+ def has_correct_url?
11
+ no_url_matches_is_provided if url_match.nil?
12
+ !(driver.url =~ url_match).nil?
13
+ end
14
+
15
+ def has_correct_title?
16
+ no_title_is_provided if page_title.nil?
17
+ !(driver.title.match(page_title)).nil?
18
+ end
19
+
20
+ def url
21
+ self.class.url
22
+ end
23
+
24
+ def url_match
25
+ self.class.url_match
26
+ end
27
+
28
+ def page_title
29
+ self.class.page_title
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ module Symbiont
2
+ module Platform
3
+ # @return [Object] browser driver reference
4
+ attr_reader :driver
5
+
6
+ # @param driver [Object] a tool driver instance
7
+ def initialize(driver)
8
+ Symbiont.trace("Dialect attached to driver:\n\t#{driver.inspect}")
9
+ @driver = driver
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
- module Symbiont
2
- VERSION = "0.2.1"
3
- end
1
+ module Symbiont
2
+ VERSION = '0.3.0'
3
+ end
data/lib/symbiont.rb CHANGED
@@ -1,92 +1,34 @@
1
- require 'symbiont/version'
2
- require 'symbiont/logger'
3
- require 'symbiont/platforms'
4
- require 'symbiont/generators'
5
- require 'symbiont/factory'
6
- require 'symbiont/enclosers'
7
- require 'symbiont/evaluators'
8
- require 'symbiont/locators'
9
- require 'symbiont/data_setter'
10
-
11
- module Symbiont
12
- include Platforms
13
- include Enclosers
14
- include Evaluators
15
- include Locators
16
- include DataSetter
17
-
18
- # Used to make a platform object accessible. Will hold object
19
- # references like these:
20
- # <Symbiont::Platforms::WatirWebDriver::PlatformObject:0x2cbe8a0>
21
- attr_reader :platform
22
-
23
- def self.version
24
- "Symbiont v#{Symbiont::VERSION}"
25
- end
26
-
27
- # The included callback is used to provide the core functionality of the
28
- # library to any class or module that includes the Symbiont library. The
29
- # calling class or module is extended with logic that the library makes
30
- # available as class methods. Those methods will be available only in
31
- # the context of the class (definition) that included Symbiont.
32
- def self.included(caller)
33
- Symbiont::trace("#{caller.class} #{caller} attached the Symbiont")
34
- caller.extend Symbiont::Generators
35
- caller.extend Symbiont::Enclosers
36
- end
37
-
38
- # Returns the default wait value for pages. This value is the default
39
- # value beyond which a timeout is assumed.
40
- def self.page_level_wait
41
- @page_wait ||= 15
42
- end
43
-
44
- def self.page_level_wait=(value)
45
- @page_wait = value
46
- end
47
-
48
- # Returns the default wait value for elements on a page. This value is
49
- # the default value beyond which a timeout is assumed.
50
- def self.element_level_wait
51
- @element_wait ||= 5
52
- end
53
-
54
- def self.element_level_wait=(value)
55
- @element_wait = value
56
- end
57
-
58
- # The initialize method will be invoked when a page definition includes
59
- # Symbiont. Some key things are happening here that are critical to
60
- # Symbiont working correctly:
61
- # (1) A browser instance is being created.
62
- # (2) A platform object is created for that browser.
63
- #
64
- # @param [Object] browser a browser instance with a tool driver
65
- # @param [boolean] visit if true, a definition will be navigated to
66
- def initialize(browser, visit=nil)
67
- Symbiont::trace("Symbiont attached to browser: #{browser}")
68
- @browser = browser
69
- establish_platform_object_for(browser)
70
- view if visit && respond_to?(:view)
71
- start if visit && respond_to?(:start)
72
- end
73
-
74
- private
75
-
76
- # This method is crucial in that it sets up the platform instance that
77
- # will be used by just about every module that makes calls to any
78
- # platform-specific functionality.
79
- #
80
- # @param [Object] browser a browser instance with a tool driver
81
- def establish_platform_object_for(browser)
82
- @platform = get_platform_for(browser)
83
- end
84
-
85
- # This method processes a block with single or multiple parameters.
86
- #
87
- # @param [Proc] block the block to process
88
- def process_block(&block)
89
- block.arity == 1 ? block.call(self) : self.instance_eval(&block)
90
- end
91
-
92
- end
1
+ require 'watir-webdriver'
2
+
3
+ require 'symbiont/version'
4
+ require 'symbiont/logging'
5
+ require 'symbiont/errors'
6
+ require 'symbiont/helpers'
7
+
8
+ require 'colorize'
9
+
10
+ require 'symbiont/platform'
11
+ require 'symbiont/assertions'
12
+ require 'symbiont/pages'
13
+ require 'symbiont/elements'
14
+ require 'symbiont/accessor'
15
+ require 'symbiont/factory'
16
+
17
+ module Symbiont
18
+ include Platform
19
+
20
+ # @param caller [Class] the class including the framework
21
+ def self.included(caller)
22
+ caller.extend Symbiont::Assertion
23
+ caller.extend Symbiont::Element
24
+
25
+ caller.send :include, Symbiont::Page
26
+ caller.send :include, Symbiont::Accessor
27
+
28
+ Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
29
+ end
30
+ end
31
+
32
+ def attach(mod=Symbiont)
33
+ include mod
34
+ end
@@ -0,0 +1,32 @@
1
+ shared_examples_for 'element generator for' do |elements|
2
+ elements.each do |element|
3
+
4
+ context "#{element} on the watir-webdriver platform" do
5
+ it "will locate a specific #{element} with a single locator" do
6
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
7
+ expect(watir_definition.send "#{element}").to eq(watir_element)
8
+ end
9
+
10
+ it "will locate a specific #{element} with a proc" do
11
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
12
+ expect(watir_definition.send "#{element}_proc").to eq(watir_element)
13
+ end
14
+
15
+ it "will locate a specific #{element} with a lambda" do
16
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
17
+ expect(watir_definition.send "#{element}_lambda").to eq(watir_element)
18
+ end
19
+
20
+ it "will locate a specific #{element} with a block" do
21
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
22
+ expect(watir_definition.send "#{element}_block", element).to eq(watir_element)
23
+ end
24
+
25
+ it "will locate a specific #{element} with a block and argument" do
26
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
27
+ expect(watir_definition.send "#{element}_block_arg", element).to eq(watir_element)
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'watir-webdriver'
2
+
3
+ def mock_browser_for_watir
4
+ watir_browser = double('watir')
5
+ watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
6
+ watir_browser.stub(:is_a?).with(Selenium::WebDriver::Driver).and_return(false)
7
+ watir_browser
8
+ end
@@ -0,0 +1,36 @@
1
+ class PageWithMissingAssertions
2
+ attach Symbiont
3
+ end
4
+
5
+ class TestFactory
6
+ include Symbiont::Factory
7
+ attr_accessor :driver
8
+ attr_accessor :active
9
+ end
10
+
11
+ class ValidPageNewContext
12
+ attach Symbiont
13
+ end
14
+
15
+ class ValidPage
16
+ attach Symbiont
17
+
18
+ url_is 'http://localhost:9292'
19
+ url_matches /:\d{4}/
20
+ title_is 'Dialogic'
21
+
22
+ %w(text_field button).each do |element|
23
+ send element, :"#{element}", id: element
24
+
25
+ send element, :"#{element}_proc", proc { driver.send(element, id: element) }
26
+ send element, :"#{element}_lambda", -> { driver.send(element, id: element) }
27
+
28
+ send element, :"#{element}_block" do
29
+ driver.send(element, id: element)
30
+ end
31
+
32
+ send element, :"#{element}_block_arg" do |id|
33
+ driver.send(element, id: id)
34
+ end
35
+ end
36
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,98 +1,49 @@
1
- $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
1
+ require 'simplecov'
2
+ require 'coveralls'
2
3
 
3
- require 'watir-webdriver'
4
+ Coveralls.wear!
4
5
 
5
- require 'simplecov'
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
6
10
 
7
11
  SimpleCov.start do
8
- add_filter "/spec/"
9
- coverage_dir "output/coverage"
10
- end if ENV['COVERAGE']
12
+ add_filter '/spec'
13
+ coverage_dir "#{SimpleCov.root}/spec/reports/coverage"
14
+ minimum_coverage 90
15
+ maximum_coverage_drop 5
16
+ end
11
17
 
12
18
  require 'symbiont'
13
19
 
14
- class DefinitionTest
15
- include Symbiont
16
-
17
- url_is "http://localhost:9292"
18
- begin_at "http://localhost:9292"
19
- title_is "Symbiote"
20
-
21
- look_for :name
22
-
23
- text_field :name, id: "name"
24
- text_field :email do |element|
25
- "email"
20
+ RSpec.configure do |config|
21
+ original_stderr = $stderr
22
+ original_stdout = $stdout
23
+ config.before(:all) do
24
+ $stderr = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
25
+ $stdout = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
26
26
  end
27
-
28
- text_area :summary, id: "summary"
29
- text_area :description do |element|
30
- "description"
27
+ config.after(:all) do
28
+ $stderr = original_stderr
29
+ $stdout = original_stdout
31
30
  end
32
31
 
33
- hidden_field :ssn, id: "ssn"
34
- hidden_field :visa do |element|
35
- "visa"
36
- end
37
-
38
- paragraph :first, id: "first"
39
- p :last, id: "last"
40
- paragraph :middle do |element|
41
- "middle"
42
- end
32
+ config.alias_it_should_behave_like_to :provides_an, 'when providing an'
43
33
 
44
- link :welcome, id: "welcome"
45
- link :greetings do |element|
46
- "greetings"
47
- end
48
-
49
- button :login, id: "login"
50
- button :logout do |element|
51
- "logout"
52
- end
53
-
54
- checkbox :apply_tax, id: "apply_tax"
55
- checkbox :apply_fee do |element|
56
- "apply_fee"
57
- end
58
-
59
- select_list :concepts, id: "concepts"
60
- select_list :topics do |element|
61
- "topics"
62
- end
63
-
64
- radio :include_tax, id: "include_tax"
65
- radio :include_fee do |element|
66
- "include_fee"
67
- end
68
-
69
- div :section, id: "section"
70
- div :aside do |element|
71
- "aside"
72
- end
73
-
74
- span :inline, id: "inline"
75
- span :part do |element|
76
- "part"
77
- end
78
-
79
- table :accounts, id: "accounts"
80
- table :invoices do |element|
81
- "invoices"
82
- end
34
+ shared_context :page do
35
+ let(:watir_browser) { mock_browser_for_watir }
36
+ let(:watir_definition) { ValidPage.new(watir_browser) }
83
37
 
84
- cell :total, id: "total"
85
- cell :sum do |element|
86
- "sum"
38
+ let(:empty_definition) { PageWithMissingAssertions.new(watir_browser) }
39
+ let(:no_driver_definition) { ValidPage.new(:unknown) }
87
40
  end
88
41
 
89
- frame(id: "frame") do |frame|
90
- text_field :framedLoginName, id: "framedLoginName", frame: frame
42
+ shared_context :element do
43
+ let(:watir_element) { double('element') }
91
44
  end
92
45
  end
93
46
 
94
- def mock_browser_for_watir
95
- watir_browser = double('watir')
96
- watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
97
- watir_browser
47
+ Dir['spec/fixtures/**/*.rb'].each do |file|
48
+ require file.sub(/spec\//, '')
98
49
  end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::Assertion do
4
+ context 'a definition with valid assertions' do
5
+ it 'will allow a url to be asserted' do
6
+ expect {
7
+ class PageWithUrl
8
+ attach Symbiont
9
+ url_is 'http://localhost:9292'
10
+ end
11
+ }.not_to raise_error
12
+ end
13
+
14
+ it 'will allow a url match pattern to be asserted' do
15
+ expect {
16
+ class PageWithUrlMatches
17
+ attach Symbiont
18
+ url_matches /localhost/
19
+ end
20
+ }.not_to raise_error
21
+ end
22
+
23
+ it 'will allow a title to be asserted' do
24
+ expect {
25
+ class PageWithTitle
26
+ attach Symbiont
27
+ title_is 'Dialogic'
28
+ end
29
+ }.not_to raise_error
30
+ end
31
+ end
32
+
33
+ context 'a definition with missing assertion values' do
34
+ it 'will indicate a missing url_is assertion value' do
35
+ expect {
36
+ class PageWithMissingUrl
37
+ attach Symbiont
38
+ url_is
39
+ end
40
+ }.to raise_error Symbiont::Errors::NoUrlForDefinition
41
+ end
42
+
43
+ it 'will indicate an empty url_is assertion value' do
44
+ expect {
45
+ class PageWithEmptyUrl
46
+ attach Symbiont
47
+ url_is ''
48
+ end
49
+ }.to raise_error Symbiont::Errors::NoUrlForDefinition
50
+ end
51
+
52
+ it 'will indicate a missing url_matches assertion value' do
53
+ expect {
54
+ class PageWithMissingUrlMatch
55
+ attach Symbiont
56
+ url_matches
57
+ end
58
+ }.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
59
+ end
60
+
61
+ it 'will indicate an empty url_matches assertion value' do
62
+ expect {
63
+ class PageWithEmptyUrlMatch
64
+ attach Symbiont
65
+ url_matches ''
66
+ end
67
+ }.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
68
+ end
69
+
70
+ it 'will indicate a missing title_is assertion value' do
71
+ expect {
72
+ class PageWithMissingTitle
73
+ attach Symbiont
74
+ title_is
75
+ end
76
+ }.to raise_error Symbiont::Errors::NoTitleForDefinition
77
+ end
78
+
79
+ it 'will indicate an empty title_is assertion value' do
80
+ expect {
81
+ class PageWithEmptyTitle
82
+ attach Symbiont
83
+ title_is ''
84
+ end
85
+ }.to raise_error Symbiont::Errors::NoTitleForDefinition
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Page Definitions' do
4
+ include_context :page
5
+
6
+ context 'a definition using watir-webdriver' do
7
+ context 'with a url_is assertion' do
8
+ it 'will call the driver navigation method when viewed' do
9
+ watir_browser.should_receive(:goto).twice
10
+ expect { watir_definition.view }.not_to raise_error
11
+ watir_definition.view
12
+ end
13
+ end
14
+
15
+ context 'with a url_matches assertion' do
16
+ it 'will verify a url if the url_matches assertion has been set' do
17
+ watir_browser.should_receive(:url).twice.and_return('http://localhost:9292')
18
+ expect { watir_definition.has_correct_url? }.not_to raise_error
19
+ watir_definition.has_correct_url?.should be_true
20
+ end
21
+
22
+ it 'will not verify a url if the url does not match the url_matches assertion' do
23
+ watir_browser.should_receive(:url).and_return('http://127.0.0.1')
24
+ watir_definition.has_correct_url?.should be_false
25
+ end
26
+ end
27
+
28
+ context 'with a title_is assertion' do
29
+ it 'will verify a title if the title_is assertion has been set' do
30
+ watir_browser.should_receive(:title).twice.and_return 'Dialogic'
31
+ expect { watir_definition.has_correct_title? }.not_to raise_error
32
+ watir_definition.has_correct_title?.should be_true
33
+ end
34
+
35
+ it 'will not verify a title if the title does not match the title_is assertion' do
36
+ watir_browser.should_receive(:title).and_return('Page Title')
37
+ watir_definition.has_correct_title?.should be_false
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::Element do
4
+ include_context :page
5
+ include_context :element
6
+
7
+ provides_an 'element generator for', %w{text_field button}
8
+ end