parameterized_testing-rspec 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
+ SHA256:
3
+ metadata.gz: 1aac7cb97d57c502628bbefe2a3d9786d682217c92a794bfe1bd3d34421d32cf
4
+ data.tar.gz: 702ea1e122d8e928089def95d337b681b093e67ff2e72648806cc0841203f9c0
5
+ SHA512:
6
+ metadata.gz: 271791288d9136390efd6c86764a4cef5c302493402174c717e133c16664170f1ef72a693bdee85fe27b2dd9a0c1f2d798c18a3b6ab67d3fa02bf8ae4eb6e55e
7
+ data.tar.gz: 4c208cefe8fc989ad933e7c420682d111836d06a8bd9a7a9b4431a37dd79351d05be03002c50197b330ae2fd224fd64ea94b874068176e6b63cb629c08a7c933
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::RSpec
2
+
3
+ Parameterized testing utility for RSpec.
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,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ParameterizedTesting
4
+ module RSpec
5
+ # The parameterized testing driver for RSpec.
6
+ # This module is automatically extended to `RSpec::Core::ExampleGroup`.
7
+ module Driver
8
+ # Entry point of the parameterized testing for RSpec.
9
+ # @param params [Array<Symbol>] parameter names
10
+ def parameterized(*params, &)
11
+ signature = ::ParameterizedTesting::Signature.new(*params)
12
+
13
+ ::ParameterizedTesting::Input.collect(&).each do |input|
14
+ # Each input corresponds to a context:
15
+ context(input.label) do
16
+ # Declare each parameter with a let:
17
+ signature.params.each do |param|
18
+ let(param) { __send__(signature.temporary_variable_name).fetch(param) }
19
+ end
20
+
21
+ # Each parameter refers this temporary variable:
22
+ let(signature.temporary_variable_name) do
23
+ signature.map(instance_exec(&input.initializer)) or
24
+ raise ::ParameterizedTesting::RSpec::InvalidInputFormatError.new(input:, signature:)
25
+ end
26
+
27
+ @_parameterized_testing_ctx = true
28
+ instance_exec(&)
29
+ end
30
+ end
31
+ end
32
+
33
+ def input(...)
34
+ raise ParameterizedTesting::RSpec::InvalidInputCallError unless @_parameterized_testing_ctx
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ module RSpec
41
+ module Core
42
+ class ExampleGroup
43
+ extend ::ParameterizedTesting::RSpec::Driver
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ParameterizedTesting
4
+ module RSpec
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rspec/version"
4
+ require_relative "rspec/driver"
5
+
6
+ module ParameterizedTesting
7
+ module RSpec
8
+ # Error raised when the format of the parameterized test input is incorrect.
9
+ class InvalidInputFormatError < Exception # rubocop:disable Lint/InheritException
10
+ attr_reader :input, :signature
11
+
12
+ def initialize(message = nil, input:, signature:)
13
+ @input = input
14
+ @signature = signature
15
+ super(message)
16
+ end
17
+ end
18
+
19
+ # Error raised when the input block is called outside of the parameterized test.
20
+ class InvalidInputCallError < Exception # rubocop:disable Lint/InheritException
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: parameterized_testing-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yubrot
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: parameterized_testing
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: Parameterized testing utility for RSpec
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/rspec.rb
51
+ - lib/parameterized_testing/rspec/driver.rb
52
+ - lib/parameterized_testing/rspec/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 RSpec
80
+ test_files: []