cuke_master 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ce1860b98075600fd4bd08947c7817e7df499ff
4
- data.tar.gz: ae1d87ac953f37a4b767719374d1749aea909575
3
+ metadata.gz: f16be9a7ced714bfa403092481c1d9cf15f9252a
4
+ data.tar.gz: 70fbf52ddebf07dac599c75184be59e2264b4232
5
5
  SHA512:
6
- metadata.gz: dbdbb6ddde0664b5a06daea8d49e10b77a15b9a60486c58fd08077ff59ae7b094107f1ac4d0d4cfdd8238cd7da483f4160500a057f99b39c16b4b602c7b38729
7
- data.tar.gz: d793d2fd59f20c0ce1bc6687f959d3de93170bebe3e79c405ffe5f59ec1072dc3fa67f84cb1b84684a0ac5a9122a77603cd7c1a950350c498a1bc460b7a88984
6
+ metadata.gz: 9dc5e84e3be35ce15db21dbca7b06e5b2095d37fc4123264f6f9957f655bd400b2bf626ee3abd65e6b7c0a32399aac948b123e0cdb3cfb134cc19b04a47d7eed
7
+ data.tar.gz: ca15e65626f2ba82733316b619e35d1e294906a071647aab09e3e39dde2019b70c53d022e0d47fee9f66df68635353c7cb9031fc33a7e391b2fdcc5a9bc1d741
@@ -1,5 +1,5 @@
1
- # rubocop:disable Lint/Debugger, HandleExceptions
2
1
  # rubocop:disable BlockLength
2
+ # rubocop:disable LineLength
3
3
  require 'securerandom'
4
4
 
5
5
  # 1. ========= BROWSE ACTIONS ===========
@@ -32,14 +32,14 @@ end
32
32
  # 2.1 Click on a button or a link
33
33
  When(/^I click on "([^"]*)"$/) do |content|
34
34
  el = first(:xpath, ".//*[contains(text(), '#{content}')]")
35
- el = first(:xpath, ".//*[@value='#{content}']") unless el
35
+ el ||= first(:xpath, ".//*[@value='#{content}']")
36
36
  el.click
37
37
  end
38
38
 
39
39
  # 2.2 Click on a button (in case you have a link with the same display)
40
40
  When(/^I click on button "([^"]*)"$/) do |content|
41
41
  el = first(:xpath, ".//button[contains(text(), '#{content}')]")
42
- el = first(:xpath, ".//input[@value='#{content}']") unless el
42
+ el ||= first(:xpath, ".//input[@value='#{content}']")
43
43
  el.click
44
44
  end
45
45
 
@@ -58,10 +58,8 @@ When(/^I click on "([^"]*)" with attribute "([^"]*)" value "([^"]*)"$/) \
58
58
  do |content, attribute, attribute_value|
59
59
  el = first(:xpath, ".//*[contains(text(), '#{content}') and \
60
60
  contains(@#{attribute}, '#{attribute_value}')]")
61
- unless el
62
- el = first(:xpath, ".//input[@value='#{content}' and \
61
+ el ||= first(:xpath, ".//input[@value='#{content}' and \
63
62
  contains(@#{attribute}, '#{attribute_value}')]")
64
- end
65
63
  el.click
66
64
  end
67
65
 
@@ -96,8 +94,7 @@ end
96
94
  When(/^I click on the ([^"]*) "([^"]*)" with attribute "([^"]*)" value \
97
95
  "([^"]*)" within the same box as "([^"]*)" with attribute "([^"]*)" value \
98
96
  "([^"]*)" as "([^"]*)"$/) \
99
- do |position, tag, attribute, attribute_value, box_tag, \
100
- box_attribute_name, box_attribute_value, seeable_content|
97
+ do |position, tag, attribute, attribute_value, box_tag, box_attribute_name, box_attribute_value, seeable_content|
101
98
  parent_el =
102
99
  find(:xpath,
103
100
  ".//#{box_tag}[contains(@#{box_attribute_name}, \
@@ -379,51 +376,64 @@ value "([^"]*)"$/) do |name, tag, attribute, value|
379
376
  end
380
377
 
381
378
  # ============== TRANSFORMING =====================
382
- Transform(/^\[([^"]*)\]$/) do |string|
383
- val = instance_variable_get("@#{string}")
384
- if val
385
- val
386
- else
387
- string
388
- end
389
- end
379
+ ParameterType(
380
+ name: 'variable',
381
+ regexp: /^\[([^"]*)\]$/,
382
+ transformer: lambda { |string|
383
+ val = instance_variable_get("@#{string}")
384
+ if val
385
+ val
386
+ else
387
+ string
388
+ end
389
+ }
390
+ )
390
391
 
391
392
  # 8.1 Transform date & time
392
- Transform(/^([^"]*) from now( with format ([^"]*))?$/) \
393
- do |string, _tmp, format|
394
- number = string.split(' ')[0]
395
- unit = string.split(' ')[1]
396
- date_format = case format
397
- when 'd-m-y'
398
- '%d-%m-%Y'
399
- when 'y-m-d'
400
- '%Y-%m-%d'
401
- when 'm-d-y'
402
- '%m-%d-%Y'
403
- else
404
- '%d-%m-%Y'
405
- end
406
- (Date.today + number.to_i.send(unit)).strftime(date_format)
407
- end
408
-
409
- Transform(/^([^"]*) prior to now( with format ([^"]*))?$/) \
410
- do |string, _tmp, format|
411
- number = string.split(' ')[0]
412
- unit = string.split(' ')[1]
413
- date_format = case format
414
- when 'd-m-y'
415
- '%d-%m-%Y'
416
- when 'y-m-d'
417
- '%Y-%m-%d'
418
- when 'm-d-y'
419
- '%m-%d-%Y'
420
- else
421
- '%d-%m-%Y'
422
- end
423
- (Date.today - number.to_i.send(unit)).strftime(date_format)
424
- end
425
-
426
- Transform(/^(first|second|third|fourth|fifth) last$/) \
427
- do |string|
428
- "#{string}_last"
429
- end
393
+ ParameterType(
394
+ name: 'date',
395
+ regexp: /^([^"]*) from now( with format ([^"]*))?$/,
396
+ transformer: lambda { |string, format|
397
+ number = string.split(' ')[0]
398
+ unit = string.split(' ')[1]
399
+ date_format = case format
400
+ when 'd-m-y'
401
+ '%d-%m-%Y'
402
+ when 'y-m-d'
403
+ '%Y-%m-%d'
404
+ when 'm-d-y'
405
+ '%m-%d-%Y'
406
+ else
407
+ '%d-%m-%Y'
408
+ end
409
+ (Date.today + number.to_i.send(unit)).strftime(date_format)
410
+ }
411
+ )
412
+
413
+ ParameterType(
414
+ name: 'date_before',
415
+ regexp: /^([^"]*) prior to now( with format ([^"]*))?$/,
416
+ transformer: lambda { |string, format|
417
+ number = string.split(' ')[0]
418
+ unit = string.split(' ')[1]
419
+ date_format = case format
420
+ when 'd-m-y'
421
+ '%d-%m-%Y'
422
+ when 'y-m-d'
423
+ '%Y-%m-%d'
424
+ when 'm-d-y'
425
+ '%m-%d-%Y'
426
+ else
427
+ '%d-%m-%Y'
428
+ end
429
+ (Date.today - number.to_i.send(unit)).strftime(date_format)
430
+ }
431
+ )
432
+
433
+ ParameterType(
434
+ name: 'order',
435
+ regexp: /^(first|second|third|fourth|fifth) last$/,
436
+ transformer: lambda { |string|
437
+ "#{string}_last"
438
+ }
439
+ )
@@ -1,3 +1,3 @@
1
1
  module CukeMaster
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Huynh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-21 00:00:00.000000000 Z
11
+ date: 2018-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.5.1
165
+ rubygems_version: 2.6.11
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Cuke Master Steps