minitest-keyword 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 +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +11 -0
- data/.travis.yml +7 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/lib/minitest/keyword/version.rb +5 -0
- data/lib/minitest/keyword.rb +63 -0
- data/minitest-keyword.gemspec +32 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 88c45029ebc3e0ed80c93e43cc14c1158b2af479
|
4
|
+
data.tar.gz: 151557967681a6fb8a3da72e4efac0e3f965bea7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce9eb124236528069c6658d0caf49d35aa04bcc274f14dc2e6c194be6b535615a70674cfd9c41b3bc7b362981b8c72e39c712fd9a8390d0d966ee0fa444c710c
|
7
|
+
data.tar.gz: 7011f1dcc776b55a7647aba423683f6aca1eda1129c3844ca86041e42c4b3b91319b40ae3c8e6178e5cafeb021b503539f124866a83c0bfc0fb7cc612b644537
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kevin Deisz
|
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
|
+
# Minitest::Keyword
|
2
|
+
|
3
|
+
[](https://travis-ci.org/kddeisz/minitest-keyword)
|
4
|
+
[](https://coveralls.io/github/kddeisz/minitest-keyword?branch=master)
|
5
|
+
[](https://rubygems.org/gems/minitest-keyword)
|
6
|
+
|
7
|
+
A small gem for allowing you to use Minitest assertions with keyword arguments. No longer worry about remembering the order of arguments!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'minitest-keyword'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install minitest-keyword
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Add `require 'minitest-keyword'` to the top of your `test_helper.rb` script. In your tests you will now be able to change your assertions from:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
assert_equal 'foo', foo.inspect
|
31
|
+
```
|
32
|
+
|
33
|
+
to:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
assert_equal exp: 'foo', act: foo.inspect
|
37
|
+
```
|
38
|
+
|
39
|
+
All of the standard Minitest assertions can now be used with keyword arguments. Note that this gem is still backwards-compatible with Minitest itself, so your existing tests won't break.
|
40
|
+
|
41
|
+
## Development
|
42
|
+
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
44
|
+
|
45
|
+
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).
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kddeisz/minitest-keyword.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
require 'minitest/keyword/version'
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
# The module containing overridden assertion methods that will be prepended
|
6
|
+
# into the Test class
|
7
|
+
module Keyword
|
8
|
+
# Raised if someone tries to pass both the regular arguments and the
|
9
|
+
# keyword arguments
|
10
|
+
class OverloadedArgumentError < ArgumentError
|
11
|
+
def initialize(method_name, argument_name)
|
12
|
+
super('Cannot specify keyword argument and pass regular argument to ' \
|
13
|
+
"#{method_name} for argument #{argument_name}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Raised if a parameter is required but none was provided as either a
|
18
|
+
# regular argument or a keyword argument
|
19
|
+
class MissingRequiredArgumentError < ArgumentError
|
20
|
+
def initialize(method_name, argument_name)
|
21
|
+
super("You must specify a value for the #{argument_name} argument " \
|
22
|
+
"for the #{method_name} assertion")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Assertions.instance_methods.grep(/assert|refute/).each do |method_name|
|
27
|
+
parameters = Assertions.instance_method(method_name).parameters
|
28
|
+
next if parameters.empty?
|
29
|
+
|
30
|
+
define_method(method_name) do |*args, **kwargs, &block|
|
31
|
+
passed_params =
|
32
|
+
parameters.map.with_index do |(type, arg_name), index|
|
33
|
+
if args.length > index && kwargs.key?(arg_name)
|
34
|
+
raise OverloadedArgumentError.new(method_name, arg_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
if args.length <= index && !kwargs.key?(arg_name) && type == :req
|
38
|
+
raise MissingRequiredArgumentError.new(method_name, arg_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
if type == :rest
|
42
|
+
args.any? ? args[index..-1] : kwargs[arg_name]
|
43
|
+
else
|
44
|
+
args[index] || kwargs[arg_name]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Special case for behavior like `assert_raises`, where a splat takes
|
49
|
+
# all of the types of errors for rescue
|
50
|
+
if parameters.length == 1 && parameters[0][0] == :rest
|
51
|
+
passed_params.flatten!(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
super(*passed_params, &block)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Hook into the Minitest::Test class and prepend the Keyword module
|
60
|
+
class Test
|
61
|
+
prepend Keyword
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'minitest/keyword/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'minitest-keyword'
|
9
|
+
spec.version = Minitest::Keyword::VERSION
|
10
|
+
spec.authors = ['Kevin Deisz']
|
11
|
+
spec.email = ['kevin.deisz@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Use Minitest assertions with keyword arguments'
|
14
|
+
spec.homepage = 'https://github.com/kddeisz/minitest-keyword'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.required_ruby_version = '>= 2.1.0'
|
25
|
+
spec.add_dependency 'minitest', '~> 5.0'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
28
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
29
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.48'
|
31
|
+
spec.add_development_dependency 'simplecov', '~> 0.14'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-keyword
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Deisz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '12.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '12.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.48'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.48'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.14'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.14'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- kevin.deisz@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- lib/minitest/keyword.rb
|
114
|
+
- lib/minitest/keyword/version.rb
|
115
|
+
- minitest-keyword.gemspec
|
116
|
+
homepage: https://github.com/kddeisz/minitest-keyword
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 2.1.0
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.6.11
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Use Minitest assertions with keyword arguments
|
140
|
+
test_files: []
|