parameterized_testing-minitest-spec 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +9 -0
- data/lib/parameterized_testing/minitest/spec/driver.rb +51 -0
- data/lib/parameterized_testing/minitest/spec/version.rb +9 -0
- data/lib/parameterized_testing/minitest/spec.rb +30 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fef6084b7c5514528d6336ad704e6d55517b5fa2e14c22b0065b33ec3abb4df6
|
4
|
+
data.tar.gz: 36777b4a521c08ecb7de81bdcd50152d37dbad077c3c1ea27921e8c01e270b1f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '039f6503449e9a1096a70f1bc3b7168613b48f3d85c04605de568f1823533d2829fc7d7fadd44591f2192742e64ff1e1e15f8a2c96dfdac56eb1de011fe13689'
|
7
|
+
data.tar.gz: 9f08140da1039afbc600cf36be005ae70f9ad345583dd7210f52f1a6272263bcf2b90fd3ea81fb804feef2d0bbe403f8a60a4dd264b6df629e0df4b81fea9220
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 yubrot
|
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,9 @@
|
|
1
|
+
# ParameterizedTesting::Minitest::Spec
|
2
|
+
|
3
|
+
Parameterized testing utility for [minitest/spec](https://github.com/minitest/minitest).
|
4
|
+
|
5
|
+
See [the repository root documentation](https://github.com/yubrot/ruby_parameterized_testing).
|
6
|
+
|
7
|
+
## License
|
8
|
+
|
9
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "minitest/spec"
|
4
|
+
|
5
|
+
module ParameterizedTesting
|
6
|
+
module Minitest
|
7
|
+
module Spec
|
8
|
+
# The parameterized testing driver for minitest/spec.
|
9
|
+
# This module is automatically extended to {Minitest::Spec}.
|
10
|
+
module Driver
|
11
|
+
# Entry point of the parameterized testing for minitest/spec.
|
12
|
+
# See https://github.com/yubrot/ruby_parameterized_testing
|
13
|
+
# @param params [Array<Symbol>] parameter names
|
14
|
+
def parameterized(*params, &)
|
15
|
+
signature = ::ParameterizedTesting::Signature.new(*params)
|
16
|
+
|
17
|
+
::ParameterizedTesting::Input.collect(&).each do |input|
|
18
|
+
# Each input corresponds to a describe:
|
19
|
+
describe(input.label) do
|
20
|
+
# Declare each parameter with a let:
|
21
|
+
signature.params.each do |param|
|
22
|
+
let(param) { __send__(signature.temporary_variable_name).fetch(param) }
|
23
|
+
end
|
24
|
+
|
25
|
+
# Each parameter refers this temporary variable:
|
26
|
+
let(signature.temporary_variable_name) do
|
27
|
+
signature.map(instance_exec(&input.initializer)) or
|
28
|
+
raise ::ParameterizedTesting::Minitest::Spec::InvalidInputFormatError.new(input:, signature:)
|
29
|
+
end
|
30
|
+
|
31
|
+
@_parameterized_testing_ctx = true
|
32
|
+
instance_exec(&)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @!visibility private
|
38
|
+
def input(...)
|
39
|
+
raise ParameterizedTesting::Minitest::Spec::InvalidInputCallError unless @_parameterized_testing_ctx
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# @!visibility private
|
47
|
+
module Minitest
|
48
|
+
class Spec
|
49
|
+
extend ::ParameterizedTesting::Minitest::Spec::Driver
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "parameterized_testing"
|
4
|
+
|
5
|
+
require_relative "spec/version"
|
6
|
+
require_relative "spec/driver"
|
7
|
+
|
8
|
+
module ParameterizedTesting
|
9
|
+
module Minitest
|
10
|
+
module Spec
|
11
|
+
# Error raised when the format of the parameterized test input is incorrect.
|
12
|
+
class InvalidInputFormatError < Exception # rubocop:disable Lint/InheritException
|
13
|
+
# @return [Input]
|
14
|
+
attr_reader :input
|
15
|
+
# @return [Signature]
|
16
|
+
attr_reader :signature
|
17
|
+
|
18
|
+
def initialize(message = nil, input:, signature:)
|
19
|
+
@input = input
|
20
|
+
@signature = signature
|
21
|
+
super(message)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Error raised when the input block is called outside of the parameterized test.
|
26
|
+
class InvalidInputCallError < Exception # rubocop:disable Lint/InheritException
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: parameterized_testing-minitest-spec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yubrot
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-10 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: parameterized_testing
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.0
|
41
|
+
description: Parameterized testing utility for minitest/spec
|
42
|
+
email:
|
43
|
+
- yubrot@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE.txt
|
49
|
+
- README.md
|
50
|
+
- lib/parameterized_testing/minitest/spec.rb
|
51
|
+
- lib/parameterized_testing/minitest/spec/driver.rb
|
52
|
+
- lib/parameterized_testing/minitest/spec/version.rb
|
53
|
+
homepage: https://github.com/yubrot/ruby_parameterized_testing
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata:
|
57
|
+
homepage_uri: https://github.com/yubrot/ruby_parameterized_testing
|
58
|
+
source_code_uri: https://github.com/yubrot/ruby_parameterized_testing
|
59
|
+
changelog_uri: https://github.com/yubrot/ruby_parameterized_testing/blob/main/CHANGELOG.md
|
60
|
+
rubygems_mfa_required: 'true'
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.1.0
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubygems_version: 3.5.9
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Parameterized testing utility for minitest/spec
|
80
|
+
test_files: []
|