pickles 0.1.10 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +75 -0
- data/lib/cucumber/pickles/config.rb +2 -2
- data/lib/cucumber/pickles/helpers.rb +1 -0
- data/lib/cucumber/pickles/helpers/node_finders.rb +4 -1
- data/lib/cucumber/pickles/locator/wait.rb +21 -0
- data/lib/cucumber/pickles/steps/can_see.rb +17 -17
- data/lib/cucumber/pickles/steps/check_in/factory.rb +18 -3
- data/lib/cucumber/pickles/steps/fill.rb +2 -0
- data/lib/cucumber/pickles/steps/fill_in/factory.rb +2 -2
- data/lib/cucumber/pickles/transform.rb +13 -1
- data/lib/cucumber/pickles/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67d811b15d2ba4b98a659537383cc987a9427d5e
|
4
|
+
data.tar.gz: be4c82f13dbfa6efa300ab8e844ddf0bd5e5f296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23913ff9c5bf8e8e82965e70f29c88d8b26fa36ac0c5db70f4d210e0194152a4e3cc93fbf47ec4ea66385869bb363fb7e88d4e37e0358be53ea25388d67ac1a2
|
7
|
+
data.tar.gz: 9c033d6bc6bd0de0df2e4f9aa44f6d7824554d3f0900aaac033dbcea74b7a7a680d2e2a47d0f106934e7eb5be64496b598e9a09b185d631f8a66d7165bacb8da
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,38 @@
|
|
1
1
|
# Pickles
|
2
|
+
<details>
|
3
|
+
<summary> Available steps summary </summary>
|
4
|
+
|
5
|
+
```rb
|
6
|
+
When I click "My button"
|
7
|
+
When I click "=Mo"
|
8
|
+
When I click ">Mo"
|
9
|
+
When I navigate:
|
10
|
+
| click | My button |
|
11
|
+
| hover | My span |
|
12
|
+
|
13
|
+
When I fill in the following:
|
14
|
+
| User data | Sex (select) | Male |
|
15
|
+
| | Avatar | avatar.png |
|
16
|
+
|
17
|
+
When I attach the file "test.png" to "Avatar" within "User data"
|
18
|
+
When I fill "Name" with "Peter" within "User data"
|
19
|
+
When I fill "Avatar" with "test.png" within "User data"
|
20
|
+
|
21
|
+
Then fields are filled with:
|
22
|
+
| Account Number | 5002 |
|
23
|
+
| Expiry date | 2009-11-01 |
|
24
|
+
|
25
|
+
Then I can see:
|
26
|
+
| form | Sarah |
|
27
|
+
| menu_item "profile change" | admin |
|
28
|
+
|
29
|
+
Then I can see video "cool_stuff"
|
30
|
+
Then I cannot see image "test.png"
|
31
|
+
Then focus is on "Sample"
|
32
|
+
Then focus is on form_field "Fill user data"
|
33
|
+
```
|
34
|
+
|
35
|
+
</details>
|
2
36
|
|
3
37
|
This gem contains some helpers to simplify testing with capybara along with afew predefined cucumber steps.
|
4
38
|
|
@@ -300,6 +334,47 @@ Mostly usefull if you're building a SPA app or just have tons of javascript and
|
|
300
334
|
+ Check fields filled by `I fill in the folllwing`
|
301
335
|
+ Supports exact same table syntax and optional column
|
302
336
|
|
337
|
+
`Then I can(not)? see:`
|
338
|
+
##### Examples:
|
339
|
+
```rb
|
340
|
+
Then I can see:
|
341
|
+
| form | Sarah |
|
342
|
+
| menu_item "profile change" | admin |
|
343
|
+
```
|
344
|
+
##### Description:
|
345
|
+
+ First column is optional for identifying within blocks
|
346
|
+
|
347
|
+
`Then I can(not)? see video (".*?")( within (?:.*))?`
|
348
|
+
|
349
|
+
##### Examples:
|
350
|
+
```rb
|
351
|
+
Then I can see video "cool_stuff"
|
352
|
+
```
|
353
|
+
|
354
|
+
##### Description:
|
355
|
+
+ value is src link to the video ( i.e. youtube link )
|
356
|
+
|
357
|
+
`Then I can(not)? see image (".*?")( within (?:.*))?`
|
358
|
+
|
359
|
+
##### Examples:
|
360
|
+
```rb
|
361
|
+
Then I cannot see image "test.png"
|
362
|
+
```
|
363
|
+
|
364
|
+
##### Description:
|
365
|
+
+ value is image_url ( i.e. assets/images/first.png )
|
366
|
+
|
367
|
+
`Then focus is on (.*) ?"(.*?)"`
|
368
|
+
|
369
|
+
##### Examples:
|
370
|
+
```rb
|
371
|
+
Then focus is on "Sample"
|
372
|
+
Then focus is on form_field "Fill user data"
|
373
|
+
```
|
374
|
+
|
375
|
+
##### Description:
|
376
|
+
+ first matching group is optional and used from node maps ( see #detect_node )
|
377
|
+
|
303
378
|
## Contributing
|
304
379
|
|
305
380
|
Bug reports and pull requests are welcome on GitHub at https://github.com/vshaveyko/pickles.
|
@@ -41,13 +41,13 @@ class Pickles::Config
|
|
41
41
|
def fill_tag_steps_map=(map)
|
42
42
|
raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)
|
43
43
|
|
44
|
-
@fill_tag_steps_map.merge!(map)
|
44
|
+
@fill_tag_steps_map.merge!(map.stringify_keys)
|
45
45
|
end
|
46
46
|
|
47
47
|
def check_tag_steps_map=(map)
|
48
48
|
raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)
|
49
49
|
|
50
|
-
@check_tag_steps_map.merge!(map)
|
50
|
+
@check_tag_steps_map.merge!(map.stringify_keys)
|
51
51
|
end
|
52
52
|
|
53
53
|
def step_by_tag(tag)
|
@@ -76,11 +76,14 @@ module NodeFinders
|
|
76
76
|
#
|
77
77
|
def find_input(input_locator, within: nil, options: {})
|
78
78
|
within ||= Capybara.current_session
|
79
|
-
options[:visible] = false
|
80
79
|
|
81
80
|
locator, index = Locator::Index.execute(input_locator)
|
81
|
+
locator, wait = Locator::Wait.execute(locator)
|
82
82
|
locator, label_xpath = Locator::Equal.execute(locator)
|
83
83
|
|
84
|
+
options[:visible] = false
|
85
|
+
options[:wait] = wait if wait
|
86
|
+
|
84
87
|
if index
|
85
88
|
index_xpath = "[#{index}]"
|
86
89
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Locator::Wait
|
2
|
+
|
3
|
+
WAIT_REGEX = /\A([^\p{L}]*)(>)(.*)\Z/
|
4
|
+
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def execute(locator)
|
8
|
+
matches = WAIT_REGEX.match(locator)
|
9
|
+
|
10
|
+
if matches
|
11
|
+
captures = matches.captures
|
12
|
+
locator = "#{captures[0]}#{captures[2]}"
|
13
|
+
|
14
|
+
[locator, nil]
|
15
|
+
else
|
16
|
+
|
17
|
+
[locator, 0]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -51,20 +51,20 @@ And(/^I can(not)? see image (".*?")( within (?:.*))?$/) do |is_not, image_src, w
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
54
|
+
Then /^focus is on (.*) ?"(.*?)"$/ do |identifier, locator|
|
55
|
+
node = if identifier
|
56
|
+
Pickles.detect_node(identifier, locator)
|
57
|
+
else
|
58
|
+
Pickles.find_node(locator, within: page)
|
59
|
+
end
|
60
|
+
|
61
|
+
block_scroll = page.evaluate_script("arguments[0].offsetTop", node)
|
62
|
+
|
63
|
+
window_height = page.evaluate_script('window.innerHeight') / 2
|
64
|
+
|
65
|
+
Waiter.wait do
|
66
|
+
scrolled = page.evaluate_script('document.body.scrollTop')
|
67
|
+
|
68
|
+
(scrolled <= block_scroll && block_scroll <= scrolled + window_height) || raise(Capybara::ElementNotFound)
|
69
|
+
end
|
70
|
+
end
|
@@ -9,13 +9,17 @@ class CheckIn::Factory
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
-
if
|
12
|
+
if in_quotes?
|
13
|
+
remove_quotes!
|
14
|
+
end
|
15
|
+
|
16
|
+
if !@value.nil? && @value[':'] && !in_quotes?
|
13
17
|
step = CheckIn::ComplexInput
|
14
18
|
# return if text_complex_input(label, value, within)
|
15
19
|
elsif @label =~ TAG
|
16
20
|
@label = $1
|
17
|
-
tag
|
18
|
-
step
|
21
|
+
tag = $2
|
22
|
+
step = Pickles.config.check_step_by_tag(tag) || CheckIn::Input
|
19
23
|
else
|
20
24
|
step = CheckIn::Input
|
21
25
|
end
|
@@ -23,4 +27,15 @@ class CheckIn::Factory
|
|
23
27
|
step.new(@label, @value, @within)
|
24
28
|
end
|
25
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
def in_quotes?
|
33
|
+
@in_quotes ||= @value && @value[0] == "\"" && @value[-1] == "\""
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_quotes!
|
37
|
+
@value[0] = ''
|
38
|
+
@value[-1] = ''
|
39
|
+
end
|
40
|
+
|
26
41
|
end
|
@@ -58,6 +58,8 @@ end)
|
|
58
58
|
# end
|
59
59
|
|
60
60
|
When /^(?:|I )(fill|select)(?: "([^"]*)")?(?: with "([^"]*)")?( within (?:.*))?$/ do |type, labels, value, within|
|
61
|
+
Waiter.wait_for_ajax
|
62
|
+
|
61
63
|
if type == 'select' && value.present?
|
62
64
|
FillIN::Select.new(labels, value, within).call
|
63
65
|
else
|
@@ -17,8 +17,8 @@ class FillIN::Factory
|
|
17
17
|
step = FillIN::ComplexInput
|
18
18
|
elsif @label =~ TAG
|
19
19
|
@label = $1
|
20
|
-
tag
|
21
|
-
step
|
20
|
+
tag = $2
|
21
|
+
step = Pickles.config.step_by_tag(tag) || FillIN::Input
|
22
22
|
else
|
23
23
|
step = FillIN::Input
|
24
24
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
within_reg = /\A\s*(.*)?\s*(?:["|'](.*?)["|'])?\s*\Z/
|
2
2
|
|
3
|
-
|
3
|
+
transformation = -> (within_info) do
|
4
4
|
splitted = within_info.split('within').reject(&:blank?)
|
5
5
|
|
6
6
|
|
@@ -16,3 +16,15 @@ Transform(/(within .*)$/) do |within_info|
|
|
16
16
|
within
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
transform_regex = /(within .*)$/
|
21
|
+
|
22
|
+
begin
|
23
|
+
Transform(transform_regex, &transformation)
|
24
|
+
rescue NoMethodError => err
|
25
|
+
ParameterType(
|
26
|
+
name: 'within',
|
27
|
+
regexp: transform_regex,
|
28
|
+
transformer: transformation
|
29
|
+
)
|
30
|
+
end
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/cucumber/pickles/helpers/waiter.rb
|
101
101
|
- lib/cucumber/pickles/locator/equal.rb
|
102
102
|
- lib/cucumber/pickles/locator/index.rb
|
103
|
+
- lib/cucumber/pickles/locator/wait.rb
|
103
104
|
- lib/cucumber/pickles/refinements.rb
|
104
105
|
- lib/cucumber/pickles/steps.rb
|
105
106
|
- lib/cucumber/pickles/steps/can_see.rb
|