tooth 0.1.0 → 0.2.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 (2) hide show
  1. data/lib/tooth.rb +2 -75
  2. metadata +2 -2
data/lib/tooth.rb CHANGED
@@ -1,76 +1,3 @@
1
- module PageObject
2
- def within scope_locator, &block
3
- within_scope_klass = Class.new
4
- within_scope_klass.extend PageObject
5
- within_scope_klass.instance_variable_set :@page_element, page_element
6
- within_scope_klass.element_with_finders = -> { element_with_finders.find(scope_locator) }
7
- within_scope_klass.class_eval &block
8
- end
9
-
10
- def link name, locator
11
- page_element[name] = ->(*args){ element_with_finders.find_link(locator_string(locator, args)) }
12
- end
13
-
14
- def field name, locator
15
- page_element[name] = ->(*args){ element_with_finders.find_field(locator_string(locator, args)) }
16
- end
17
-
18
- def button name, locator
19
- page_element[name] = ->(*args){ element_with_finders.find_button(locator_string(locator, args)) }
20
- end
21
-
22
- def element name, locator, options = {}
23
- page_element[name] = ->(*args){
24
- element_with_finders.find(locator_string(locator, args), options)
25
- }
26
- end
27
-
28
- def component name, component_class, locator, options = {}
29
- page_element[name] = ->(*args){
30
- component_element = find(locator_string(locator, args), options)
31
- component_class.tap do |cmp|
32
- cmp.element_with_finders = component_element
33
- end
34
- }
35
- end
36
-
37
- # convenience methods
38
- def shows? &block
39
- instance_eval &block
40
- end
41
- alias :scenario :shows?
42
-
43
- def not_shows? &block
44
- instance_eval &block
45
- rescue Capybara::ElementNotFound
46
- else
47
- raise 'Element is shown'
48
- end
49
- protected
50
- # currently this is not thread safe solution, because we do not create instance of component, but reuse component class.
51
- # here we trade usability of the framework for the thread safeness. Need to think about this issue and better solutions.
52
- attr_writer :element_with_finders
53
-
54
- private
55
- def locator_string(locator, args)
56
- locator.kind_of?(Proc) ? locator.call(*args) : locator
57
- end
58
-
59
- def page_element; @page_element ||= {} end
60
-
61
- def element_with_finders
62
- if @element_with_finders
63
- @element_with_finders.kind_of?(Proc) ? @element_with_finders.call : @element_with_finders
64
- else
65
- Capybara.current_session
66
- end
67
- end
68
-
69
- def method_missing(meth, *args, &block)
70
- if( element_finder = page_element[meth.to_sym])
71
- element_finder.call(*args)
72
- else
73
- element_with_finders.send(meth, *args, &block)
74
- end
75
- end
1
+ module Tooth
2
+ require 'tooth/page_object'
76
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tooth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-12 00:00:00.000000000 Z
12
+ date: 2013-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara