rspec-parameterized-table_syntax 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 21c64d788d2f64fea8e46866a5939c3cdd398fe67299efb1996ff842bba57baa
4
+ data.tar.gz: 402ffbe3117092de17896e05e42f940e08cb5175b1d763df397b078c954e07dc
5
+ SHA512:
6
+ metadata.gz: f16bb37557b87ae5b11a9b3036509f6859ff8f428f15ba41ace57fd9267d63c307c98eafb537c37a1b6934b12fb10ccd902c2603fe0ab26647047748fb89cdf3
7
+ data.tar.gz: fa800e051768fb1214b25bca817cdac8be1598062bfef8e0e120fe39f93f03fe0a611cc9fb9d62c3c159a7526b5490915e592306d53611560ebfc07313160ab9
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-31
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rspec-parameterized-table_syntax.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 sue445
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,35 @@
1
+ # Rspec::Parameterized::TableSyntax
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec/parameterized/table_syntax`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec-parameterized-table_syntax.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: %i[spec]
@@ -0,0 +1,51 @@
1
+ module RSpec
2
+ module Parameterized
3
+ module TableSyntax
4
+ class Table
5
+ attr_reader :last_row
6
+
7
+ def initialize
8
+ @rows = []
9
+ @last_row = nil
10
+ end
11
+
12
+ def add_row(row)
13
+ unless @rows.find {|r| r.object_id == row.object_id}
14
+ @rows << row
15
+ @last_row = row
16
+ end
17
+ self
18
+ end
19
+
20
+ def add_param_to_last_row(param)
21
+ last_row.add_param(param)
22
+ self
23
+ end
24
+ alias :| :add_param_to_last_row
25
+
26
+ def to_a
27
+ @rows.map(&:to_a)
28
+ end
29
+ alias :to_params :to_a
30
+
31
+ class Row
32
+ def initialize(param)
33
+ @params = [param]
34
+ end
35
+
36
+ def add_param(param)
37
+ @params << param
38
+ end
39
+
40
+ def to_a
41
+ @params
42
+ end
43
+
44
+ def to_params
45
+ [@params]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ module RSpec
2
+ module Parameterized
3
+ module TableSyntax
4
+ module TableSyntaxImplement
5
+ def |(other)
6
+ where_binding = binding.of_caller(1) # get where block binding
7
+ caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)
8
+
9
+ if caller_instance.instance_variable_defined?(:@__parameter_table)
10
+ table = caller_instance.instance_variable_get(:@__parameter_table)
11
+ else
12
+ table = RSpec::Parameterized::TableSyntax::Table.new
13
+ caller_instance.instance_variable_set(:@__parameter_table, table)
14
+ end
15
+
16
+ row = Table::Row.new(self)
17
+ table.add_row(row)
18
+ row.add_param(other)
19
+ table
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rspec
4
+ module Parameterized
5
+ module TableSyntax
6
+ VERSION = "1.0.0.beta1"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/parameterized/table_syntax/version"
4
+ require 'rspec/parameterized/table_syntax/table'
5
+ require 'rspec/parameterized/table_syntax/table_syntax_implement'
6
+ require "rspec/parameterized/core"
7
+ require 'binding_of_caller'
8
+
9
+ module RSpec
10
+ module Parameterized
11
+ module TableSyntax
12
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.2.0.rc1")
13
+ refine Object do
14
+ import_methods TableSyntaxImplement
15
+ end
16
+
17
+ refine Integer do
18
+ import_methods TableSyntaxImplement
19
+ end
20
+
21
+ refine Array do
22
+ import_methods TableSyntaxImplement
23
+ end
24
+
25
+ refine NilClass do
26
+ import_methods TableSyntaxImplement
27
+ end
28
+
29
+ refine TrueClass do
30
+ import_methods TableSyntaxImplement
31
+ end
32
+
33
+ refine FalseClass do
34
+ import_methods TableSyntaxImplement
35
+ end
36
+ else
37
+ refine Object do
38
+ include TableSyntaxImplement
39
+ end
40
+
41
+ refine Integer do
42
+ include TableSyntaxImplement
43
+ end
44
+
45
+ refine Array do
46
+ include TableSyntaxImplement
47
+ end
48
+
49
+ refine NilClass do
50
+ include TableSyntaxImplement
51
+ end
52
+
53
+ refine TrueClass do
54
+ include TableSyntaxImplement
55
+ end
56
+
57
+ refine FalseClass do
58
+ include TableSyntaxImplement
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rspec/parameterized/table_syntax/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rspec-parameterized-table_syntax"
7
+ spec.version = Rspec::Parameterized::TableSyntax::VERSION
8
+ spec.authors = ["sue445", "tomykaira", "joker1007"]
9
+ spec.email = ["sue445@sue445.net", "tomykaira@gmail.com"]
10
+
11
+ spec.description = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.}
12
+ spec.summary = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.
13
+ I was inspired by [udzura's mock](https://gist.github.com/1881139).}
14
+
15
+ spec.homepage = "https://github.com/rspec-parameterized/rspec-parameterized-table_syntax"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 2.6.0"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "binding_of_caller"
35
+ spec.add_dependency "rspec-parameterized-core"
36
+
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec"
39
+
40
+ # For more information and examples about making a new gem, check out our
41
+ # guide at: https://bundler.io/guides/creating_gem.html
42
+ end
@@ -0,0 +1,8 @@
1
+ module Rspec
2
+ module Parameterized
3
+ module TableSyntax
4
+ VERSION: String
5
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
+ end
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-parameterized-table_syntax
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - sue445
8
+ - tomykaira
9
+ - joker1007
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2022-12-31 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: binding_of_caller
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec-parameterized-core
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ description: RSpec::Parameterized supports simple parameterized test syntax in rspec.
72
+ email:
73
+ - sue445@sue445.net
74
+ - tomykaira@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".rspec"
80
+ - CHANGELOG.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - lib/rspec/parameterized/table_syntax.rb
86
+ - lib/rspec/parameterized/table_syntax/table.rb
87
+ - lib/rspec/parameterized/table_syntax/table_syntax_implement.rb
88
+ - lib/rspec/parameterized/table_syntax/version.rb
89
+ - rspec-parameterized-table_syntax.gemspec
90
+ - sig/rspec/parameterized/table_syntax.rbs
91
+ homepage: https://github.com/rspec-parameterized/rspec-parameterized-table_syntax
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ homepage_uri: https://github.com/rspec-parameterized/rspec-parameterized-table_syntax
96
+ source_code_uri: https://github.com/rspec-parameterized/rspec-parameterized-table_syntax
97
+ changelog_uri: https://github.com/rspec-parameterized/rspec-parameterized-table_syntax/blob/main/CHANGELOG.md
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.6.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">"
110
+ - !ruby/object:Gem::Version
111
+ version: 1.3.1
112
+ requirements: []
113
+ rubygems_version: 3.2.22
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: RSpec::Parameterized supports simple parameterized test syntax in rspec.
117
+ I was inspired by [udzura's mock](https://gist.github.com/1881139).
118
+ test_files: []