magic_steps 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7078a6cf421234993970312d443729f05e4f7fd2
4
+ data.tar.gz: ee16fbf71f1b220507bc98f17a1213dbf03eba6e
5
+ SHA512:
6
+ metadata.gz: a19245e355dfb79bf08798cbab6137aa0f447218d994e90228496949ba2bdbfa61e3fd75b48896a12fdaaed05ddb920a99f37c9e1a5a6e9e583883bf4f53cb37
7
+ data.tar.gz: 41e0241cc8b0568a926bbc0610eb1645cc99126ad5a8634bf8fa5c450798c70d8b83ee79f41e8c8637592dbc6e497c0fd5df5361e6d22cacb0f63906a02f4c31
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Magic Steps
2
+
3
+ Helper Cucumber steps for Web, Api, and App based frameworks
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'magic_steps'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install magic_steps
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
+
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
37
+
@@ -0,0 +1,2 @@
1
+ require 'magic_steps/page_object/actions'
2
+ require 'magic_steps/page_object/verifications'
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ Given(/^I visit the \[(.*)\] page$/) do |page|
3
+ visit(page)
4
+ end
5
+
6
+ When(/^(?:I|If I) wait for \((\d+)\) seconds$/) do |amount|
7
+ sleep(amount.to_i)
8
+ end
9
+
10
+ When(/^I refresh the page$/) do
11
+ @current_page.refresh
12
+ end
13
+
14
+ When(/^I inspect [(\w+)]$/) do |element|
15
+ @current_page.send("#{element}_element").inspect
16
+ end
17
+
18
+ When(/^I click on \[(\w+)\]$/) do |object|
19
+ @current_page.send("#{object}_element").when_present.click
20
+ end
21
+
22
+
23
+ Then(/^I should( not)? see {(.*)} on the page$/) do |negated, text|
24
+ if negated
25
+ expect(@current_page.text).not_to include text
26
+ else
27
+ expect(@current_page.text).to include text
28
+ end
29
+ end
30
+
31
+ Then(/^I take a screenshot$/) do
32
+ file = Tempfile.new(['requested_screenshot', '.png'])
33
+ @browser.screenshot.save(file.path)
34
+ attach_file('Requested Screenshot', File.open(file.path))
35
+ end
36
+
37
+ Then(/^I pry$/) do
38
+ binding.pry
39
+ end
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+ # Count References
3
+ Then(/^all \[(\w+)\] should be visible$/) do |ref|
4
+ expect { @current_page.ref_to_arr(ref).select(&:visible?).size }.to eventually eql(@current_page.ref_to_arr(ref).size), "#{ref} visibility"
5
+ end
6
+
7
+ Then(/^\((\d+)\) \[(\w+)\] should be visible$/) do |expected, ref|
8
+ expect { @current_page.ref_to_arr(ref).select(&:visible?).size }.to eventually eql(expected.to_i), "#{ref} visibility"
9
+ end
10
+
11
+ Then(/^\((\d+)\) or more \[(\w+)\] should be visible$/) do |expected, ref|
12
+ expect { @current_page.ref_to_arr(ref).select(&:visible?).size }.to eventually be >= (expected.to_i), "#{ref} visibility"
13
+ end
14
+
15
+
16
+ # Count Criteria of References
17
+ Then(/^\((\d+)\) \[(\w+)\] should have \((\d+)\) \[(\w+)\] visible$/) do |exp_ref, ref, exp_sub_ref, sub_ref|
18
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size == exp_sub_ref.to_i }.size }.to eventually eql(exp_ref.to_i), "#{ref} #{sub_ref} visibility"
19
+ end
20
+
21
+ Then(/^\((\d+)\) or more \[(\w+)\] should have \((\d+)\) \[(\w+)\] visible$/) do |exp_ref, ref, exp_sub_ref, sub_ref|
22
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size == exp_sub_ref.to_i }.size }.to eventually be >=(exp_ref.to_i), "#{ref} #{sub_ref} visibility"
23
+ end
24
+
25
+ Then(/^\((\d+)\) \[(\w+)\] should have \((\d+)\) or more \[(\w+)\] visible$/) do |exp_ref, ref, exp_sub_ref, sub_ref|
26
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size >= exp_sub_ref.to_i }.size }.to eventually eql(exp_ref.to_i), "#{ref} #{sub_ref} visibility"
27
+ end
28
+
29
+ Then(/^\((\d+)\) or more \[(\w+)\] should have \((\d+)\) or more \[(\w+)\] visible$/) do |exp_ref, ref, exp_sub_ref, sub_ref|
30
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size >= exp_sub_ref.to_i }.size }.to eventually be >=(exp_ref.to_i), "#{ref} #{sub_ref} visibility"
31
+ end
32
+
33
+ Then(/^all \[(\w+)\] should have \((\d+)\) or more \[(\w+)\] visible$/) do |ref, exp_sub_ref, sub_ref|
34
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size >= exp_sub_ref.to_i }.size }.to eventually eql(@current_page.ref_to_arr(ref).size), "#{ref} #{sub_ref} visibility"
35
+ end
36
+
37
+ Then(/^all \[(\w+)\] should have \((\d+)\) \[(\w+)\] visible$/) do |ref, exp_sub_ref, sub_ref|
38
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size == exp_sub_ref.to_i }.size }.to eventually eql(@current_page.ref_to_arr(ref).size), "#{ref} #{sub_ref} visibility"
39
+ end
40
+
41
+ Then(/^all \[(\w+)\] should have all \[(\w+)\] visible$/) do |ref, sub_ref|
42
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |element| element.visible? }.size == sub_ref.to_i }.size }.to eventually eql(@current_page.ref_to_arr(ref).size), "#{ref} #{sub_ref} visibility"
43
+ end
44
+
45
+ # Count Criteria of of Sub-References
46
+ Then(/^\((\d+)\) \[(\w+)\] should have \((\d+)\) \[(\w+)\] where \((\d+)\) \[(\w+)\] is visible$/) do |exp_ref, ref, exp_sub_ref, sub_ref, exp_sub_criteria, sub_criteria|
47
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |section| section.ref_to_arr(sub_criteria).select { |element| element.visible? }.size == exp_sub_criteria.to_i }.size == exp_sub_ref.to_i }.size }.to eventually eq(exp_ref.to_i), "#{ref} #{sub_ref} #{sub_criteria} visibility"
48
+ end
49
+
50
+ Then(/^all \[(\w+)\] should have \((\d+)\) \[(\w+)\] where \((\d+)\) \[(\w+)\] is visible$/) do |ref, exp_sub_ref, sub_ref, exp_sub_criteria, sub_criteria|
51
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |section| section.ref_to_arr(sub_criteria).select { |element| element.visible? }.size == exp_sub_criteria.to_i }.size == exp_sub_ref.to_i }.size }.to eventually eql(@current_page.ref_to_arr(ref).size), "#{ref} #{sub_ref} #{sub_criteria} visibility"
52
+ end
53
+
54
+ Then(/^\((\d+)\) \[(\w+)\] should have all \[(\w+)\] where \((\d+)\) \[(\w+)\] is visible$/) do |exp_ref, ref, sub_ref, exp_sub_criteria, sub_criteria|
55
+ expect { @current_page.ref_to_arr(ref).select { |section| section.ref_to_arr(sub_ref).select { |section| section.ref_to_arr(sub_criteria).select { |element| element.visible? }.size == exp_sub_criteria.to_i }.size == section.ref_to_arr(sub_ref).size }.size }.to eventually eql(exp_ref.to_i), "#{ref} #{sub_ref} #{sub_criteria} visibility"
56
+ end
57
+
58
+
59
+ # Page Sections Child should equal int / text
60
+ Then(/^\[(\w+)\] \((\d+)\)s \[(\w+)\] should be \((\d+)\)$/) do |ref, lookup, criteria, expected|
61
+ expect { @current_page.get_int(@current_page.ref_to_arr(ref)[lookup.to_i-1].send("#{criteria}_element")) }.to eventually eql(expected.to_i), "#{ref} #{lookup}'s #{criteria} visibility"
62
+ end
63
+
64
+ Then(/^\[(\w+)\] \((\d+)\)s \[(\w+)\] should be {(.*)}$/) do |ref, lookup, criteria, expected|
65
+ expect { @current_page.ref_to_arr(ref)[lookup.to_i-1].send("#{criteria}_element").attribute('textContent').downcase.include?(expected.downcase) }.to eventually be_truthy(), "#{ref} #{lookup}'s #{criteria} visibility"
66
+ end
67
+
68
+ # Page Section Criteria should equal int / text
69
+ Then(/^the \[(\w+)\] \[(\w+)\] should be \((\d+)\)$/) do |ref, criteria, expected|
70
+ expect { @current_page.get_int(@current_page.ref_to_arr(ref).flat_map { |s| s.ref_to_arr(criteria) }) }.to eventually eql(expected.to_i), "#{ref} #{criteria} visibility"
71
+ end
72
+
73
+
74
+ # Elements should be enabled / disabled
75
+ Then(/^the \[(\w+)\] should be enabled$/) do |ref|
76
+ expect { @current_page.ref_to_arr(ref) }.to eventually all be_enabled
77
+ end
78
+
79
+ Then(/^the \[(\w+)\] should be disabled$/) do |ref|
80
+ expect { @current_page.ref_to_arr(ref).map { |e| e.exists? && e.enabled? } }.to eventually_not include be_truthy
81
+ end
82
+
83
+ # Sub Elements should be enabled / disabled
84
+ Then(/^the \[(\w+)\] \[(\w+)\] should be enabled$/) do |ref, sub_ref|
85
+ expect { @current_page.ref_to_arr(ref).flat_map { |section| section.ref_to_arr(sub_ref) }.select(&:enabled?) }.to eventually all be_truthy
86
+ end
87
+
88
+ Then(/^the \[(\w+)\] \[(\w+)\] should be disabled$/) do |ref, sub_ref|
89
+ expect { @current_page.ref_to_arr(ref).flat_map { |section| section.ref_to_arr(sub_ref) }.select(&:enabled?) }.to eventually_not all be_truthy
90
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: magic_steps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Commu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Use this library to add cucumber step helpers to your test frameworks
14
+ email:
15
+ - services@automationwizards.ca
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - lib/magic_steps.rb
22
+ - lib/magic_steps/page_object/actions.rb
23
+ - lib/magic_steps/page_object/verifications.rb
24
+ homepage: https://automationwizards.ca
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.5.1
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Helper Cucumber steps for web, api, and app
48
+ test_files: []