site_prism 2.5 → 2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +14 -16
- data/README.md +38 -1
- data/lib/site_prism/element_container.rb +17 -4
- data/lib/site_prism/version.rb +1 -1
- metadata +20 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27fcff1ed1e931ef4062524d0dfcc302cd889dce
|
4
|
+
data.tar.gz: 14fd216ac58ed422963b2acbd0874ff3993382d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 232a21ab0d139cc1390708d301ea7b4a24540da96a9b02702b6cfe70e8ffa063dce028c177b843dd6b581747bd3015eaeccc0296cfb1763a99de75e2821be701
|
7
|
+
data.tar.gz: 63d72784da0d0e39b8c9649f2f7bb78b566403b4394c69aea4fac56f5427921cf72281a0bc93ecdd3b968b5370240aede5f3f38768399dacf0a70c74173682d3
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2011, Nathaniel Ritmeyer
|
1
|
+
Copyright (c) 2011-2014, Nathaniel Ritmeyer
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without
|
@@ -11,19 +11,17 @@ this list of conditions and the following disclaimer.
|
|
11
11
|
notice, this list of conditions and the following disclaimer in the
|
12
12
|
documentation and/or other materials provided with the distribution.
|
13
13
|
|
14
|
-
3. Neither the name
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
19
|
-
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
20
|
-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21
|
-
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
22
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
25
|
-
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
26
|
-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
27
|
-
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
28
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
14
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
15
|
+
may be used to endorse or promote products derived from this software without
|
16
|
+
specific prior written permission.
|
29
17
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
21
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
22
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
23
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
24
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
25
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1029,6 +1029,29 @@ When /^I enter my name into the home page's registration form$/ do
|
|
1029
1029
|
end
|
1030
1030
|
```
|
1031
1031
|
|
1032
|
+
#### Anonymous Sections
|
1033
|
+
|
1034
|
+
If you want to use a section more as a namespace for elements and are not
|
1035
|
+
planning on re-using it, you may find it more convenient to define
|
1036
|
+
an anonymous section using a block:
|
1037
|
+
|
1038
|
+
```ruby
|
1039
|
+
class Home < SitePrism::Page
|
1040
|
+
section :menu, '.menu' do
|
1041
|
+
element :title, '.title'
|
1042
|
+
elements :items, 'a'
|
1043
|
+
end
|
1044
|
+
end
|
1045
|
+
```
|
1046
|
+
|
1047
|
+
This code will create an anonymous section that you can use in the same way
|
1048
|
+
as an ordinary section:
|
1049
|
+
|
1050
|
+
```ruby
|
1051
|
+
@home = Home.new
|
1052
|
+
@home.menu.should have_title
|
1053
|
+
```
|
1054
|
+
|
1032
1055
|
### Section Collections
|
1033
1056
|
|
1034
1057
|
An individual section represents a discrete section of a page, but often
|
@@ -1091,6 +1114,20 @@ element. So if the css selector finds 3 `li` elements, calling
|
|
1091
1114
|
`SearchResultSection`, each with one of the `li` elements as it's root
|
1092
1115
|
element.
|
1093
1116
|
|
1117
|
+
#### Anonymous Section Collections
|
1118
|
+
|
1119
|
+
You can define collections of anonymous sections the same way you would
|
1120
|
+
define a single anonymous section:
|
1121
|
+
|
1122
|
+
```ruby
|
1123
|
+
class SearchResults < SitePrism::Page
|
1124
|
+
sections :search_results, SearchResultSection, "#results li" do
|
1125
|
+
element :title, "a.title"
|
1126
|
+
element :blurb, "span.result-decription"
|
1127
|
+
end
|
1128
|
+
end
|
1129
|
+
```
|
1130
|
+
|
1094
1131
|
#### Testing for existence of Sections
|
1095
1132
|
|
1096
1133
|
Using the example above, it is possible to test for the existence of the
|
@@ -1364,7 +1401,7 @@ with this:
|
|
1364
1401
|
There's a SitePrism plugin called `site_prism.vcr` that lets you use
|
1365
1402
|
SitePrism with the VCR gem. Check it out here:
|
1366
1403
|
|
1367
|
-
* https://github.com/
|
1404
|
+
* https://github.com/dnesteryuk/site_prism.vcr
|
1368
1405
|
|
1369
1406
|
# Epilogue
|
1370
1407
|
|
@@ -17,7 +17,8 @@ module SitePrism::ElementContainer
|
|
17
17
|
end
|
18
18
|
alias :collection :elements
|
19
19
|
|
20
|
-
def section(section_name,
|
20
|
+
def section(section_name, *args, &block)
|
21
|
+
section_class, find_args = extract_section_options args, &block
|
21
22
|
build section_name, *find_args do
|
22
23
|
define_method section_name do | *runtime_args |
|
23
24
|
section_class.new self, find_first(*find_args, *runtime_args)
|
@@ -25,7 +26,8 @@ module SitePrism::ElementContainer
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def sections(section_collection_name,
|
29
|
+
def sections(section_collection_name, *args, &block)
|
30
|
+
section_class, find_args = extract_section_options args, &block
|
29
31
|
build section_collection_name, *find_args do
|
30
32
|
define_method section_collection_name do |*runtime_args|
|
31
33
|
find_all(*find_args, *runtime_args).collect do |element|
|
@@ -38,7 +40,6 @@ module SitePrism::ElementContainer
|
|
38
40
|
def iframe(iframe_name, iframe_page_class, selector)
|
39
41
|
element_selector = deduce_iframe_element_selector(selector)
|
40
42
|
scope_selector = deduce_iframe_scope_selector(selector)
|
41
|
-
|
42
43
|
add_to_mapped_items iframe_name
|
43
44
|
create_existence_checker iframe_name, element_selector
|
44
45
|
create_nonexistence_checker iframe_name, element_selector
|
@@ -114,7 +115,8 @@ module SitePrism::ElementContainer
|
|
114
115
|
def create_waiter(element_name, *find_args)
|
115
116
|
method_name = "wait_for_#{element_name.to_s}"
|
116
117
|
create_helper_method method_name, *find_args do
|
117
|
-
define_method method_name do |timeout =
|
118
|
+
define_method method_name do |timeout = nil, *runtime_args|
|
119
|
+
timeout = timeout.nil? ? Capybara.default_wait_time : timeout
|
118
120
|
Capybara.using_wait_time timeout do
|
119
121
|
element_exists? *find_args, *runtime_args
|
120
122
|
end
|
@@ -161,5 +163,16 @@ module SitePrism::ElementContainer
|
|
161
163
|
def deduce_iframe_element_selector(selector)
|
162
164
|
selector.is_a?(Integer) ? "iframe:nth-of-type(#{selector + 1})" : selector
|
163
165
|
end
|
166
|
+
|
167
|
+
def extract_section_options(args, &block)
|
168
|
+
if args.first.is_a? Class
|
169
|
+
section_class = args.shift
|
170
|
+
elsif block_given?
|
171
|
+
section_class = Class.new SitePrism::Section, &block
|
172
|
+
else
|
173
|
+
raise ArgumentError.new "You should provide section class either as a block, or as the second argument"
|
174
|
+
end
|
175
|
+
return section_class, args
|
176
|
+
end
|
164
177
|
end
|
165
178
|
|
data/lib/site_prism/version.rb
CHANGED
metadata
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_prism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
5
|
-
prerelease:
|
4
|
+
version: '2.6'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nat Ritmeyer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capybara
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '2.1'
|
22
20
|
- - <
|
@@ -25,46 +23,41 @@ dependencies:
|
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '2.1'
|
33
30
|
- - <
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: '3.0'
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
34
|
+
name: addressable
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ~>
|
42
38
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
39
|
+
version: 2.3.3
|
44
40
|
type: :runtime
|
45
41
|
prerelease: false
|
46
42
|
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
43
|
requirements:
|
49
44
|
- - ~>
|
50
45
|
- !ruby/object:Gem::Version
|
51
|
-
version:
|
46
|
+
version: 2.3.3
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
|
-
name:
|
48
|
+
name: rspec
|
54
49
|
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
|
-
- -
|
51
|
+
- - <
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
type: :
|
53
|
+
version: '4.0'
|
54
|
+
type: :development
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
57
|
requirements:
|
65
|
-
- -
|
58
|
+
- - <
|
66
59
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
60
|
+
version: '4.0'
|
68
61
|
description: SitePrism gives you a simple, clean and semantic DSL for describing your
|
69
62
|
site using the Page Object Model pattern, for use with Capybara
|
70
63
|
email: nat@natontesting.com
|
@@ -83,28 +76,28 @@ files:
|
|
83
76
|
- LICENSE
|
84
77
|
- README.md
|
85
78
|
homepage: http://github.com/natritmeyer/site_prism
|
86
|
-
licenses:
|
79
|
+
licenses:
|
80
|
+
- BSD3
|
81
|
+
metadata: {}
|
87
82
|
post_install_message: Make sure to add your project/company to https://github.com/natritmeyer/site_prism/wiki/Who-is-using-SitePrism
|
88
83
|
rdoc_options: []
|
89
84
|
require_paths:
|
90
85
|
- lib
|
91
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
87
|
requirements:
|
94
|
-
- -
|
88
|
+
- - '>='
|
95
89
|
- !ruby/object:Gem::Version
|
96
90
|
version: 1.9.3
|
97
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
92
|
requirements:
|
100
|
-
- -
|
93
|
+
- - '>='
|
101
94
|
- !ruby/object:Gem::Version
|
102
95
|
version: '0'
|
103
96
|
requirements: []
|
104
97
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.0.3
|
106
99
|
signing_key:
|
107
|
-
specification_version:
|
100
|
+
specification_version: 4
|
108
101
|
summary: A Page Object Model DSL for Capybara
|
109
102
|
test_files: []
|
110
103
|
has_rdoc:
|