integration_test_kit 0.1.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +101 -0
- data/Rakefile +26 -0
- data/app/assets/config/integration_test_kit_manifest.js +2 -0
- data/app/assets/javascripts/integration_test_kit/application.js +13 -0
- data/app/assets/stylesheets/integration_test_kit/application.css +15 -0
- data/app/controllers/integration_test_kit/application_controller.rb +5 -0
- data/app/controllers/integration_test_kit/commands_controller.rb +9 -0
- data/app/helpers/integration_test_kit/application_helper.rb +4 -0
- data/app/views/layouts/integration_test_kit/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/lib/integration_test_kit.rb +39 -0
- data/lib/integration_test_kit/configuration.rb +5 -0
- data/lib/integration_test_kit/engine.rb +5 -0
- data/lib/integration_test_kit/errors.rb +7 -0
- data/lib/integration_test_kit/registry.rb +9 -0
- data/lib/integration_test_kit/version.rb +3 -0
- data/lib/tasks/integration_test_kit_tasks.rake +4 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8f6dfe01264de37be1a2d7b2db367498c096cf8cf3a29df7526f9f39444a8fb
|
4
|
+
data.tar.gz: 553cb776a3acb7458d3bf62eec914c89dacda32a6cca1c99fe0349a2ec155dc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9fa65d6de8fbedcc037c15e6ff63c9783077d5a8098656b93e2c9774440c83ca96be37d5ab86c4219db7c6cc42e02e05af8a9c3214dd6475334ba812447a5374
|
7
|
+
data.tar.gz: 408bc472d8fa202c9b1df307caa7f6c47d3f6db231fa8dd9a1176e3e827c1e07018097e6a3305ccbc59dc434cf7b24b8c512ca85c4ee3390ee8855585b708537
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 OfferZen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# Integration Test Kit
|
2
|
+
|
3
|
+
[](http://hits.dwyl.io/Offerzen/integration_test_kit)
|
4
|
+
|
5
|
+
Integration Test Kit provides a small DSL for defining integration test commands, and an endpoint for calling them locally.
|
6
|
+
|
7
|
+
The initial use case was for running integration test commands for specific testing scenarios in [Cypress](https://www.cypress.io), such as cleaning the test database or creating seed data.
|
8
|
+
|
9
|
+
Integration Test Kit is inspired by the functionality of [Cypress On Rails](https://github.com/shakacode/cypress-on-rails).
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
You'll need to define commands within a directory of your choosing. Commands are set up using a simple DSL:
|
13
|
+
```ruby
|
14
|
+
IntegrationTestKit.define do
|
15
|
+
command :example do
|
16
|
+
puts 'Ruby code can be run here'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
You can then run commands with a POST to `/<name_of_mount_path>/commands?name=<name_of_command>`, or with `"name": "example"` in the body as JSON.
|
22
|
+
|
23
|
+
If you're using Cypress, you can add a command to your `support/commands.js` file to make this easier:
|
24
|
+
```js
|
25
|
+
Cypress.Commands.add('appCommand', command => {
|
26
|
+
cy.request({
|
27
|
+
method: 'POST',
|
28
|
+
url: `/<name_of_mount_path>/commands`,
|
29
|
+
body: {
|
30
|
+
name: command
|
31
|
+
}
|
32
|
+
})
|
33
|
+
})
|
34
|
+
```
|
35
|
+
|
36
|
+
## Installation
|
37
|
+
### Things to note
|
38
|
+
* Integration Test Kit is meant for usage within the test environment only. Don't include it or configure it in production.
|
39
|
+
* There is a check to ensure that the gem is only configured for the test environment during configuration and when running commands.
|
40
|
+
* The gem is a Rails Engine, and is meant for usage within a Rails application.
|
41
|
+
|
42
|
+
Add this line to your application's Gemfile in the test group:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
group :test do
|
46
|
+
gem 'integration_test_kit'
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
And then run:
|
51
|
+
```bash
|
52
|
+
$ bundle install
|
53
|
+
```
|
54
|
+
|
55
|
+
Or install it yourself as:
|
56
|
+
```bash
|
57
|
+
$ gem install integration_test_kit
|
58
|
+
```
|
59
|
+
|
60
|
+
Configure Integration Test Kit in an initializer, or in `config/environments/test.rb`. Currently, the only configuration option is the commands load path:
|
61
|
+
```ruby
|
62
|
+
IntegrationTestKit.configure do |config|
|
63
|
+
config.commands_load_path = 'spec/cypress/commands'
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Create commands within a Ruby file inside the commands load path directory (eg. `test.rb`).
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'integration_test_kit'
|
71
|
+
|
72
|
+
IntegrationTestKit.define do
|
73
|
+
command :example do
|
74
|
+
puts 'Ruby code can be run here'
|
75
|
+
end
|
76
|
+
|
77
|
+
command :another_example do
|
78
|
+
puts 'Ruby code can be run here'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
Mount the routes within your application (`routes.rb` or equivalent):
|
84
|
+
```ruby
|
85
|
+
if Rails.env.test?
|
86
|
+
mount IntegrationTestKit::Engine => '/integration_test_kit'
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
You are now able to run commands with a POST to `/integration_test_kit/commands/name=example`, or with `"name": "example"` in the body as JSON.
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
Feel free to create an issue or submit a PR.
|
94
|
+
|
95
|
+
## Release
|
96
|
+
|
97
|
+
1. [Bump the version](https://semver.org/)
|
98
|
+
2. Follow the standard [ruby gems release guide](https://bundler.io/v2.0/guides/creating_gem.html#releasing-the-gem)
|
99
|
+
|
100
|
+
## License
|
101
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'IntegrationTestKit'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Integration test kit</title>
|
5
|
+
<%= stylesheet_link_tag "integration_test_kit/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "integration_test_kit/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'integration_test_kit/engine'
|
2
|
+
require 'integration_test_kit/configuration'
|
3
|
+
require 'integration_test_kit/registry'
|
4
|
+
require 'integration_test_kit/errors'
|
5
|
+
|
6
|
+
module IntegrationTestKit
|
7
|
+
@commands = {}
|
8
|
+
|
9
|
+
def self.commands
|
10
|
+
@commands
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configuration
|
14
|
+
@configuration ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
raise EnvironmentError unless Rails.env.test?
|
19
|
+
|
20
|
+
yield configuration
|
21
|
+
|
22
|
+
Dir[Rails.root.join(configuration.commands_load_path, '*.rb')].each do |file|
|
23
|
+
require File.expand_path(file)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.run_command(name)
|
28
|
+
raise EnvironmentError unless Rails.env.test?
|
29
|
+
|
30
|
+
@commands[name.to_sym].call
|
31
|
+
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.define(&block)
|
36
|
+
registry = Registry.new
|
37
|
+
registry.instance_eval(&block)
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: integration_test_kit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ethan Marrs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Integration Test Kit provides a small DSL for defining integration test
|
70
|
+
commands, and an endpoint for calling them locally.
|
71
|
+
email:
|
72
|
+
- ethan@offerzen.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- MIT-LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- app/assets/config/integration_test_kit_manifest.js
|
81
|
+
- app/assets/javascripts/integration_test_kit/application.js
|
82
|
+
- app/assets/stylesheets/integration_test_kit/application.css
|
83
|
+
- app/controllers/integration_test_kit/application_controller.rb
|
84
|
+
- app/controllers/integration_test_kit/commands_controller.rb
|
85
|
+
- app/helpers/integration_test_kit/application_helper.rb
|
86
|
+
- app/views/layouts/integration_test_kit/application.html.erb
|
87
|
+
- config/routes.rb
|
88
|
+
- lib/integration_test_kit.rb
|
89
|
+
- lib/integration_test_kit/configuration.rb
|
90
|
+
- lib/integration_test_kit/engine.rb
|
91
|
+
- lib/integration_test_kit/errors.rb
|
92
|
+
- lib/integration_test_kit/registry.rb
|
93
|
+
- lib/integration_test_kit/version.rb
|
94
|
+
- lib/tasks/integration_test_kit_tasks.rake
|
95
|
+
homepage: https://github.com/Offerzen/integration_test_kit
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubygems_version: 3.0.3
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: A small DSL for defining and calling integration test commands.
|
118
|
+
test_files: []
|