site_prism 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,7 @@ module SitePrism::ElementContainer
23
23
  # home.should_not have_search_link
24
24
  def element element_name, element_locator
25
25
  create_existence_checker element_name, element_locator
26
+ create_waiter element_name, element_locator
26
27
  define_method element_name.to_s do
27
28
  find_one element_locator
28
29
  end
@@ -44,6 +45,7 @@ module SitePrism::ElementContainer
44
45
  # home.app_links.map {|link| link.text}.should == ['Finance', 'Maps', 'Blogs']
45
46
  def elements collection_name, collection_locator
46
47
  create_existence_checker collection_name, collection_locator
48
+ create_waiter collection_name, collection_locator
47
49
  define_method collection_name.to_s do
48
50
  find_all collection_locator
49
51
  end
@@ -77,6 +79,7 @@ module SitePrism::ElementContainer
77
79
  # @param [String] the CSS locator for the root element of the section on this page/section
78
80
  def section section_name, section_class, section_locator
79
81
  create_existence_checker section_name, section_locator
82
+ create_waiter section_name, section_locator
80
83
  define_method section_name do
81
84
  section_class.new find_one section_locator
82
85
  end
@@ -85,6 +88,7 @@ module SitePrism::ElementContainer
85
88
  # Works in the same way as {SitePrism::Page.section} but instead of it returning one section, it returns an array of them.
86
89
  def sections section_collection_name, section_class, section_collection_locator
87
90
  create_existence_checker section_collection_name, section_collection_locator
91
+ create_waiter section_collection_name, section_collection_locator
88
92
  define_method section_collection_name do
89
93
  find_all(section_collection_locator).collect do |element|
90
94
  section_class.new element
@@ -101,4 +105,11 @@ module SitePrism::ElementContainer
101
105
  element_exists? element_locator
102
106
  end
103
107
  end
108
+
109
+ # Creates a method used to wait for an element to appear - uses the default capybara wait time
110
+ def create_waiter element_name, element_locator
111
+ define_method "wait_for_#{element_name.to_s}" do
112
+ element_waiter element_locator
113
+ end
114
+ end
104
115
  end
@@ -105,5 +105,10 @@ module SitePrism
105
105
  def element_exists? locator
106
106
  has_selector? locator
107
107
  end
108
+
109
+ # Page specific element waiter
110
+ def element_waiter locator
111
+ wait_until { element_exists? locator }
112
+ end
108
113
  end
109
114
  end
@@ -28,5 +28,10 @@ module SitePrism
28
28
  def element_exists? locator
29
29
  @root_element.has_selector? locator
30
30
  end
31
+
32
+ # Section specific element waiter
33
+ def element_waiter locator
34
+ wait_until { element_exists? locator }
35
+ end
31
36
  end
32
37
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: site_prism
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.2
5
+ version: 0.9.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nat Ritmeyer
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-11 00:00:00 Z
13
+ date: 2012-02-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara