cucumber-sammies 0.1.0

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: 1493e1ca46f94974635f114d9c67c651b1ed51be
4
+ data.tar.gz: ab713fc9ce8690970eb22037ca4f467c840dfd52
5
+ SHA512:
6
+ metadata.gz: 8c185e173ad04bd24193823bc09f550f5fda65226d2b2f7b170e61fb5d42457d52204e6d64e12a6a3c6e37c7b5b38794829d525ec913d095afaa42fa569b70c5
7
+ data.tar.gz: 21e55714cd0997c6d868a5f777d3f4eb50c1eab7887218baef171364d92510fe7f8d0ac90e1b451ac0714da8c45dbd72fb40b01b47a83efbf5acf4ff0ca4d96b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ *.gem
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jskirst@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cucumber-sammies.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jonathan Kirst
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Cucumber::Sammies
2
+
3
+ [![Code Climate](https://codeclimate.com/github/starfighterheavy/cucumber-sammies/badges/gpa.svg)](https://codeclimate.com/github/starfighterheavy/cucumber-sammies)
4
+ [![Dependency Status](https://gemnasium.com/starfighterheavy/cucumber-sammies.svg)](https://gemnasium.com/starfighterheavy/cucumber-sammies)
5
+ [![Gem Version](https://badge.fury.io/rb/cucumber-sammies.svg)](https://badge.fury.io/rb/cucumber-sammies)
6
+
7
+ ![Cucumber Sandwhiches](./sammies.jpg)
8
+
9
+ Simple & tasty step definitions for your Rails application that are meant to compliment [Speewald](https://github.com/makandra/spreewald).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'cucumber-sammies'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install cucumber-sammies
26
+
27
+ ## Usage
28
+
29
+ To use `cucumber-sammies` in your cucumber tests, add this line to your `features/support/env.rb` file.
30
+
31
+ ```ruby
32
+ require 'cucumber/sammies/step_definitions/*'
33
+ ```
34
+
35
+ Or your can require individual step definition files by replacing `*` with the file name you want.
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cucumber-sammies. 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.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the Cucumber::Sammies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cucumber-sammies/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cucumber/sammies"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cucumber/sammies/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cucumber-sammies"
8
+ spec.version = Cucumber::Sammies::VERSION
9
+ spec.authors = ["Jonathan Kirst"]
10
+ spec.email = ["jskirst@gmail.com"]
11
+
12
+ spec.summary = %q{Cucumber step definitions for rails applications.}
13
+ spec.homepage = "https://github.com/starfighterheavy/cucumber-sammies"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,7 @@
1
+ require "cucumber/sammies/version"
2
+
3
+ module Cucumber
4
+ module Sammies
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # coding: UTF-8
2
+
3
+ Dir[File.join(File.dirname(__FILE__), '/step_definitions/*_steps.rb')].each do |f|
4
+ name = File.basename(f, '.rb')
5
+ require "cucumber/sammies/step_definitions/#{name}"
6
+ end
7
+
@@ -0,0 +1,15 @@
1
+ Then /^the page title should be "(.*)"$/ do |title|
2
+ expect(page.title).to eq(title)
3
+ end
4
+
5
+ Then /^the page body should include "(.*)"$/ do |content|
6
+ expect(page.body).to include(content)
7
+ end
8
+
9
+ Then(/^I see the (.*) flash message$/) do |message|
10
+ expect(page).to have_content(resolve_locale(message))
11
+ end
12
+
13
+ Then(/^I (should )?see the localized text for "(.*)"$/) do |_should, message|
14
+ expect(page).to have_content(resolve_locale(message))
15
+ end
@@ -0,0 +1,3 @@
1
+ Given /^the cookie "(.*)" is set to "(.*)"$/ do |cookie, value|
2
+ page.driver.browser.set_cookie("#{cookie}=#{value}")
3
+ end
@@ -0,0 +1,34 @@
1
+ Given 'I generate a random email' do
2
+ @email = Faker::Internet.email
3
+ end
4
+
5
+ Then /^there should be (\d+) (.*)$/ do |count, model|
6
+ expect(resolve_class(model).count).to eq(count.to_i)
7
+ end
8
+
9
+ Given /^the Rails cache is cleared$/ do
10
+ Rails.cache.clear
11
+ end
12
+
13
+ When /^the ([a-z]+) (.*) should have the ([a-z_]+) "(.*)"$/ do |ordinal, model, key, value|
14
+ expect(resolve_class(model).send(ordinal).send(key).to_s).to eq(value)
15
+ end
16
+
17
+ Then /^the ([a-z_]+) of the ([a-z]+) (.*) should be (blank|present)$/ do |key, ordinal, model, value|
18
+ expect(resolve_class(model).send(ordinal).send(key).to_s).to send("be_#{value}")
19
+ end
20
+
21
+ Then 'the JSON response should be an array that includes:' do |json|
22
+ expected = JSON.parse(json)
23
+ actual = JSON.parse(last_response.body)
24
+ expect(actual).to be_a Array
25
+ expect((expected - actual)).to be_empty
26
+ end
27
+
28
+ Then 'the JSON response should be an object that includes:' do |json|
29
+ expected = JSON.parse(json)
30
+ actual = JSON.parse(last_response.body)
31
+
32
+ expect(actual).to be_a Hash
33
+ expect((expected.to_a - actual.to_a)).to be_empty
34
+ end
@@ -0,0 +1,16 @@
1
+ Given /^the "(.*)" ENV is set to "(.*)"$/ do |key, value|
2
+ ENV[key] = value
3
+ end
4
+
5
+ Given /^the "(.*)" ENV should be set to "(.*)"$/ do |key, value|
6
+ expect(ENV[key]).to eq value
7
+ end
8
+
9
+
10
+ Then /^"(.*)" should raise a "(.*)" error$/ do |expression, error|
11
+ expect { eval(expression) }.to raise_error(/#{error}/)
12
+ end
13
+
14
+ Then /^"(.*)" should not raise a "(.*)" error$/ do |expression, error|
15
+ expect { eval(expression) }.not_to raise_error(/#{error}/)
16
+ end
@@ -0,0 +1,44 @@
1
+ When(/^I click "(.*)"$/) do |link|
2
+ click_on link
3
+ end
4
+
5
+ When(/^I click the first "(.*)"$/) do |link|
6
+ first('a,input', text: link).click
7
+ end
8
+
9
+ When(/^I click the "(.*)" submit button$/) do |link|
10
+ find(link).click
11
+ end
12
+
13
+ When(/^I check the ([^"]+) box$/) do |label|
14
+ check resolve_locale(label)
15
+ end
16
+
17
+ When(/^I check the "(.*)" box$/) do |field|
18
+ check field
19
+ end
20
+
21
+ When(/^I upload "(.*)" to "(.*)"$/) do |file_path, field|
22
+ attach_file(field, file_path)
23
+ end
24
+
25
+ When /^I select the date "(.*)" from "(.*)"$/ do |date, field|
26
+ date = date.split(' ')
27
+ if date.count == 2
28
+ month, year = date
29
+ day = nil
30
+ else
31
+ month, day, year = date
32
+ end
33
+ select_year_month(year: year, month: month, day: day, field: field)
34
+ end
35
+
36
+ def select_year_month(year:, month:, day: nil, field:)
37
+ unless field.include?('_')
38
+ field = find(:xpath, ".//label[contains(.,'#{field}')]")[:for]
39
+ field.gsub!(/_[1-3]{1}i$/, '')
40
+ end
41
+ select year, :from => "#{field}_1i"
42
+ select month, :from => "#{field}_2i"
43
+ select day, :from => "#{field}_3i" if day
44
+ end
@@ -0,0 +1,20 @@
1
+ Then(/^I am taken to (a|an|the) (.*) page$/) do |inclusive, path|
2
+ path.split(' ').each do |part|
3
+ expect(current_path.split('/')).to include(part)
4
+ end
5
+ unless inclusive == 'the'
6
+ expect(current_path.split('/').last.to_i).to be > 0
7
+ end
8
+ end
9
+
10
+ When(/^I set the subdomain to "(.*)"$/) do |subdomain|
11
+ Capybara.app_host = "http://#{subdomain}.example.com"
12
+ end
13
+
14
+ When /^I visit "(.*)"$/ do |path|
15
+ visit path
16
+ end
17
+
18
+ Then(/^I wait ([0-9]+) seconds$/) do |seconds|
19
+ sleep seconds.to_i
20
+ end
@@ -0,0 +1,23 @@
1
+ def resolve_locale(str)
2
+ str = str.gsub(/\s/, '.')
3
+ I18n.t(str)
4
+ end
5
+
6
+ def resolve_path(str)
7
+ str.gsub(' ', '_') + '_path'
8
+ end
9
+
10
+ def resolve_ivar(str)
11
+ model = str.gsub(' ', '_')
12
+ instance_variable_get("@#{model}")
13
+ end
14
+
15
+ def set_ivar(str, value)
16
+ model = str.gsub(' ', '_')
17
+ instance_variable_set("@#{model}", value)
18
+ end
19
+
20
+
21
+ def resolve_class(str)
22
+ str.singularize.titleize.gsub(' ', '').constantize
23
+ end
@@ -0,0 +1,10 @@
1
+ Then /^I should not see the table "(.*)"$/ do |caption|
2
+ expect(page).not_to have_css('caption', text: caption)
3
+ end
4
+
5
+ Then /^the table "(.*)" should contain:$/ do |caption, data|
6
+ table = page.find('caption', text: caption).first(:xpath,".//..").all('tr').map { |tr|
7
+ tr.all('th,td').map { |col| col.text }
8
+ }
9
+ data.diff!(table)
10
+ end
@@ -0,0 +1,11 @@
1
+ When /^I log the page$/ do
2
+ Cucumber.logger.info page.body
3
+ end
4
+
5
+ Then /^I pry$/ do
6
+ binding.pry
7
+ end
8
+
9
+ Then /^I sleep (.*) seconds$/ do |seconds|
10
+ sleep seconds.to_f
11
+ end
@@ -0,0 +1,5 @@
1
+ module Cucumber
2
+ module Sammies
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/sammies.jpg ADDED
Binary file
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-sammies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Kirst
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - jskirst@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - cucumber-sammies.gemspec
57
+ - lib/cucumber/sammies.rb
58
+ - lib/cucumber/sammies/step_definitions/all_steps.rb
59
+ - lib/cucumber/sammies/step_definitions/content_steps.rb
60
+ - lib/cucumber/sammies/step_definitions/cookie_steps.rb
61
+ - lib/cucumber/sammies/step_definitions/data_steps.rb
62
+ - lib/cucumber/sammies/step_definitions/environment_steps.rb
63
+ - lib/cucumber/sammies/step_definitions/form_steps.rb
64
+ - lib/cucumber/sammies/step_definitions/navigation_steps.rb
65
+ - lib/cucumber/sammies/step_definitions/resolvers.rb
66
+ - lib/cucumber/sammies/step_definitions/table_steps.rb
67
+ - lib/cucumber/sammies/step_definitions/troubleshooting_steps.rb
68
+ - lib/cucumber/sammies/version.rb
69
+ - sammies.jpg
70
+ homepage: https://github.com/starfighterheavy/cucumber-sammies
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.5.2
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Cucumber step definitions for rails applications.
94
+ test_files: []