pickles 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +203 -89
- data/lib/cucumber/pickles/steps.rb +1 -1
- data/lib/cucumber/pickles/steps/fill.rb +1 -1
- data/lib/cucumber/pickles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 288501fe87bdcd1723a59483ff8763255fdc6ad5
|
4
|
+
data.tar.gz: 8d9b503a3a2b71786f5e4c9ef19febbb1af32357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0cdd2cdd431aeb9fefb68ca162f2ff56357a68417e6461be78d4e0b9491b55f247ccc7f989067caef87008ed02fb9a88704b334d9d9e12c078f6a342c207efa
|
7
|
+
data.tar.gz: 4ab2bba90221cbc0da00ebfe784c7505434565b76532ae5f7cf5bf024716023468ebdf9ca95c6e5aca62f6b453e7d571a58a3998d071bd12060758fe6235c5ab
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ This gem contains some helpers to simplify testing with capybara along with afew
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'pickles'
|
10
|
+
gem 'pickles', require: false
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -18,15 +18,136 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install pickles
|
20
20
|
|
21
|
-
|
21
|
+
```rb
|
22
|
+
require 'cucumber/pickles/helpers' # require only helpers without steps
|
23
|
+
# or
|
24
|
+
require 'cucumber/pickles' # require everything alltogether
|
25
|
+
```
|
26
|
+
|
27
|
+
## Configure
|
28
|
+
|
29
|
+
```rb
|
30
|
+
Pickles.configure do |c|
|
31
|
+
|
32
|
+
#
|
33
|
+
# Usually referring to elements on page as .some-css-class is a bad practice.
|
34
|
+
#
|
35
|
+
# You can provide a map with aliases pointing to that stuff in this config
|
36
|
+
# Ex: c.css_node_map = { some_block: '.some-css-class' }
|
37
|
+
#
|
38
|
+
# And refer to it across within blocks in every predefined step or by manually using detect_node_helper
|
39
|
+
#
|
40
|
+
c.css_node_map = {}
|
41
|
+
# Same as above but shouled be aliased to xpath selector
|
42
|
+
c.xpath_node_map = {}
|
43
|
+
|
44
|
+
#
|
45
|
+
# Log xhr error response to browser console,
|
46
|
+
#
|
47
|
+
# You can configure capybara to log this to your console: ( For example if example failed )
|
48
|
+
#
|
49
|
+
# puts page.driver.browser.manage.logs.get('browser').select { |log| log.level == 'SEVERE' }.map(&:message).map(&:red)
|
50
|
+
#
|
51
|
+
c.log_xhr_response = false
|
52
|
+
|
53
|
+
#
|
54
|
+
# In some table steps you can provide '(...)' identifier to override how that step should be handled
|
55
|
+
#
|
56
|
+
# See 'I fill in the following:' for explaination
|
57
|
+
#
|
58
|
+
c.fill_tag_steps_map = { 'select' => Select }
|
59
|
+
|
60
|
+
#
|
61
|
+
# Same as above for 'fields are filled with:' step
|
62
|
+
#
|
63
|
+
c.check_tag_steps_map = { 'text' => Text }
|
64
|
+
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
### Capybara test helpers
|
69
|
+
|
70
|
+
Bunch of usefull helpers for everyday testing with capybara.
|
71
|
+
|
72
|
+
Mostly usefull if you're building a SPA app or just have tons of javascript and standard Capybara helper methods isnt enough.
|
73
|
+
|
74
|
+
#### Start with:
|
75
|
+
If you're using cucumber you may want to:
|
76
|
+
```rb
|
77
|
+
World(Pickles)
|
78
|
+
```
|
79
|
+
|
80
|
+
Or you can use it through:
|
81
|
+
```rb
|
82
|
+
Pickles.helper_name
|
83
|
+
```
|
84
|
+
|
85
|
+
### Index:
|
86
|
+
|
87
|
+
1. [wait_for_ajax](#wait_for_ajax)
|
88
|
+
2. [Locator string](#locator-string-text2)
|
89
|
+
3. [find_node](#find_nodelocator-within-nil)
|
90
|
+
4. [detect_node](#detect_nodeel_alias-locator--nil-within-nil)
|
91
|
+
5. [find_input](#find_inputlocator-within-nil)
|
92
|
+
6. [blur](#blurnode)
|
93
|
+
7. [select_input](#select_inputinput-value--nil)
|
94
|
+
8. [attach_file](#attach_fileinput-file_name)
|
95
|
+
|
96
|
+
+ #### Locator string: `Ex: "=Text[2]"`:
|
97
|
+
+ 'Text' - required - text to look up by
|
98
|
+
+ '=' - optional - lookup exact text in node if given
|
99
|
+
+ '[2]' - optional - index of element on page. If found 4 elements than 3rd will be selected - indexed from 0.
|
100
|
+
|
101
|
+
+ #### find_node(locator, within: nil)
|
102
|
+
|
103
|
+
Find node on page by [Locator string](#locator-string-text2)
|
104
|
+
|
105
|
+
within - capybara node to limit lookup
|
106
|
+
|
107
|
+
returns: capybara node
|
108
|
+
|
109
|
+
+ #### find_input(locator, within: nil)
|
22
110
|
|
23
|
-
|
111
|
+
Find `input | textarea | [contenteditable]` on page identified by [Locator string](#locator-string-text2)
|
112
|
+
|
113
|
+
+ #### detect_node(el_alias, locator = nil, within: nil)
|
114
|
+
|
115
|
+
Does lookup based on provided in config maps
|
116
|
+
|
117
|
+
if within.present? => limit search to within
|
118
|
+
if locator.present? => use locator in step location
|
119
|
+
|
120
|
+
Use el_alias to find needed xpath / css in maps provided to config.
|
121
|
+
Priority xpath_map => css_map => el_alias as it is
|
122
|
+
|
123
|
+
locator and el_alias can use index configuration from [Locator string](#locator-string-text2)
|
124
|
+
|
125
|
+
+ #### wait_for_ajax
|
126
|
+
|
127
|
+
Waits for ajax requests to end before proceeding further.
|
128
|
+
Terminated with `Capybara::ElementNotFound` after `Capybara.default_wait_time` seconds
|
129
|
+
|
130
|
+
+ #### blur(node)
|
131
|
+
|
132
|
+
Triggers *node* blur event and clicks on body to perform blur
|
133
|
+
|
134
|
+
+ #### select_input(input, value = nil)
|
135
|
+
|
136
|
+
Selects *input*[type="checkbox"] OR *input*[type="radio"] on form
|
137
|
+
|
138
|
+
Triggers click after selection to trigger javascript events ( may change in future )
|
139
|
+
|
140
|
+
+ #### attach_file(input, file_name)
|
141
|
+
|
142
|
+
Attaches file with *file_name* to *input*[type="file"]
|
143
|
+
|
144
|
+
*file_name* is fetched from `features/support/attachments/*file_name*` and raises RuntimeError if file not found
|
145
|
+
|
146
|
+
### Supported cucumber steps:
|
24
147
|
|
25
148
|
+ Navigation
|
26
149
|
|
27
|
-
1.
|
28
|
-
When I (?:click|navigate) "([^"]*)"( within (?:.*))?
|
29
|
-
```
|
150
|
+
1. `When I (?:click|navigate) "([^"]*)"( within (?:.*))?`
|
30
151
|
|
31
152
|
##### Examples:
|
32
153
|
```rb
|
@@ -52,30 +173,27 @@ Or install it yourself as:
|
|
52
173
|
##### Description:
|
53
174
|
+ for within checkout docs
|
54
175
|
|
55
|
-
2.
|
56
|
-
I (?:click|navigate):( within (?:.*))?
|
57
|
-
```
|
176
|
+
2. `When I (?:click|navigate):( within (?:.*))?`
|
58
177
|
|
59
178
|
##### Examples:
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
179
|
+
```rb
|
180
|
+
When I navigate:
|
181
|
+
| click | My button |
|
182
|
+
| hover | My span |
|
183
|
+
| hover | Your span |
|
184
|
+
| click | Your button |
|
185
|
+
|
186
|
+
When I navigate: within form "User data"
|
187
|
+
| click | Submit |
|
188
|
+
```
|
67
189
|
|
68
190
|
##### Description:
|
69
|
-
|
70
|
-
|
71
|
-
+ for within checkout docs
|
72
|
-
|
191
|
+
+ Same as previous, but allows table as argument.
|
192
|
+
+ note ` : ` in the definition
|
73
193
|
|
74
194
|
+ Forms:
|
75
195
|
+ Fill:
|
76
|
-
1.
|
77
|
-
When (?:|I )fill in the following:( within (?:.*))?
|
78
|
-
```
|
196
|
+
1. `When (?:|I )fill in the following:( within (?:.*))?`
|
79
197
|
|
80
198
|
##### Examples:
|
81
199
|
```rb
|
@@ -95,96 +213,92 @@ Or install it yourself as:
|
|
95
213
|
##### Description:
|
96
214
|
+ Fills form fields identified by second column.
|
97
215
|
+ First column is optional and defines 'within block' - see docs for within
|
98
|
-
+ Add custom (...) block for second column to define your own form fill steps
|
216
|
+
+ Add custom (...) block for second column to define your own form fill steps in `config.fill_tag_steps_map`
|
99
217
|
supported by default:
|
100
|
-
(select) - uses
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
218
|
+
(select) - uses `When I select ".." with ".."` under the hood.
|
219
|
+
Ex:
|
220
|
+
```rb
|
221
|
+
class FillDatepicker
|
222
|
+
|
223
|
+
def initialize(label, value, within)
|
224
|
+
# label = 'Date of birth'
|
225
|
+
@label = label
|
226
|
+
# value = '23.12.1998'
|
227
|
+
@value = Date.parse(value)
|
228
|
+
# within = detect_node("form", "User profile", within: page)
|
229
|
+
@within = within
|
230
|
+
end
|
231
|
+
|
232
|
+
def call
|
233
|
+
# implement datepicker selecting logic
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
Pickles.configure do |c|
|
238
|
+
c.fill_tag_steps_map = { datepicker: FillDatepicker }
|
239
|
+
end
|
240
|
+
|
241
|
+
When I fill in the following:
|
242
|
+
| form "User profile" | Date of birth (datepicker) | 23.12.1998 |
|
243
|
+
```
|
244
|
+
|
245
|
+
|
246
|
+
2. `When (?:|I )attach the file "([^"]*)" to "([^"]*)"( within (?:.*))?`
|
105
247
|
|
106
248
|
##### Examples:
|
107
249
|
```rb
|
108
|
-
When I
|
250
|
+
When I attach the file "test.png" to "Avatar" within "User data"
|
109
251
|
```
|
110
252
|
|
111
253
|
##### Description:
|
112
|
-
+
|
254
|
+
+ Attaches given file to identified fields
|
113
255
|
+ Params:
|
114
|
-
1.
|
115
|
-
2.
|
256
|
+
1. `features/support/attachments/` + `file_name` is used to identify file
|
257
|
+
2. Input identifier. see `find_input` helper for searching details
|
116
258
|
3. within block identifier
|
117
|
-
|
118
|
-
|
119
|
-
|
259
|
+
+ within part is optional
|
260
|
+
|
261
|
+
4. `When (?:|I )(?:fill|select)(?: "([^"]*)")?(?: with "([^"]*)")?( within (?:.*))?`
|
120
262
|
|
121
263
|
##### Examples:
|
122
264
|
```rb
|
123
|
-
When I
|
124
|
-
|
265
|
+
When I fill "Name" with "Peter" within "User data" # input[type="text"]
|
266
|
+
When I fill "Avatar" with "test.png" within "User data" # input[type="file"]
|
125
267
|
|
126
|
-
|
127
|
-
|
128
|
-
+ Params:
|
129
|
-
1. identifier for block with selected select ( see [find_node](#find_nodelocator-within-nil) )
|
130
|
-
4. ```rb
|
131
|
-
When (?:|I )attach the file "([^"]*)" to "([^"]*)"( within (?:.*))?
|
132
|
-
```
|
133
|
-
|
134
|
-
##### Examples:
|
135
|
-
```rb
|
136
|
-
When I attach the file "test.png" to "Avatar" within "User data"
|
137
|
-
```
|
268
|
+
When I fill "Male" within "User data" # input[type="checkbox"] || input[type="radio"]
|
269
|
+
When I select "Male"
|
138
270
|
|
139
|
-
|
140
|
-
+ Attaches given file to identified fields
|
141
|
-
+ Params:
|
142
|
-
1. relative file name. see attach_file
|
143
|
-
2. file input identifier. see [find_node](#find_nodelocator-within-nil)
|
144
|
-
3. within block identifier. see [find_node](#find_nodelocator-within-nil)
|
145
|
-
|
146
|
-
5. ```rb
|
147
|
-
When (?:|I )(?:fill|select|unselect)(select)?(?: "([^"]*)")?(?: with "([^"]*)")?( within (?:.*))?
|
148
|
-
```
|
271
|
+
When I select "sex" with "Male" # selector
|
149
272
|
|
150
|
-
##### Examples:
|
151
|
-
```rb
|
152
|
-
When I fill "Name" with "Peter" within "User data"
|
153
|
-
When I fill "Avatar" with "test.png" within "User data"
|
154
|
-
When I fill "Male" within "User data"
|
155
|
-
When I fill "sex" with "Male" within "User data"
|
156
273
|
```
|
157
274
|
|
158
275
|
##### Description:
|
159
276
|
+ Tries to fill data by guessing field type from found input type(text|checkbox|radio|etc)
|
160
277
|
+ There MUST always be an input identified by identifier
|
278
|
+
+ within part is optional
|
161
279
|
|
162
280
|
+ Check
|
163
|
-
1. ```rb
|
164
|
-
Then fields are filled with:( within (?:.*))?
|
165
|
-
```
|
166
281
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
+ Check fields filled by 'I fill in the folllwing'
|
184
|
-
+ Supports exact same table syntax and optional column
|
185
|
-
|
186
|
-
## Development
|
282
|
+
`Then fields are filled with:( within (?:.*))?`
|
283
|
+
|
284
|
+
##### Examples:
|
285
|
+
```rb
|
286
|
+
Then fields are filled with:
|
287
|
+
| Account Number | 5002 |
|
288
|
+
| Expiry date | 2009-11-01 |
|
289
|
+
| Note | Nice guy |
|
290
|
+
| Wants Email? | true |
|
291
|
+
| Sex | Male |
|
292
|
+
| Accept user agrement | true |
|
293
|
+
| Send me letters | false |
|
294
|
+
| radio 1 | true |
|
295
|
+
| Avatar | avatar.png |
|
296
|
+
| Due date | 12:35 |
|
297
|
+
```
|
187
298
|
|
299
|
+
##### Description:
|
300
|
+
+ Check fields filled by `I fill in the folllwing`
|
301
|
+
+ Supports exact same table syntax and optional column
|
188
302
|
|
189
303
|
## Contributing
|
190
304
|
|
@@ -57,7 +57,7 @@ end)
|
|
57
57
|
# FillIN::Select.new(label, value, within).call
|
58
58
|
# end
|
59
59
|
|
60
|
-
When /^(?:|I )(fill|select
|
60
|
+
When /^(?:|I )(fill|select)(?: "([^"]*)")?(?: with "([^"]*)")?( within (?:.*))?$/ do |type, labels, value, within|
|
61
61
|
if type == 'select' && value.present?
|
62
62
|
FillIN::Select.new(labels, value, within).call
|
63
63
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pickles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|