rspec-with_params 0.1.0

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: 3d617765fb2fa8b4be3d9977a1d3417018670b8b44841c2a6acff950a934609b
4
+ data.tar.gz: 312c62fe4fe871bb5d9aea5c5684b2172fe4d68d02e23f191158fd92b237dc37
5
+ SHA512:
6
+ metadata.gz: 12e9bec6e9c6423a8d8f4ff103f7d51d745803f324b5eebd461effd99afe985334d52bd3a0132c2fa472f8837dd3462f5ecd3695996fbd31b92686f9987ec564
7
+ data.tar.gz: b2760a7e86dac1182a3fa61303c010e6ed740e8d76704998c09c619926fcd6ebdca21857e229179bf6eb47375169f4f2207e1c9b40e1c9f5c35be551acf72930
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rspec-with_params.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-with_params (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ jet_black (0.5.1)
11
+ rake (10.5.0)
12
+ rspec (3.8.0)
13
+ rspec-core (~> 3.8.0)
14
+ rspec-expectations (~> 3.8.0)
15
+ rspec-mocks (~> 3.8.0)
16
+ rspec-core (3.8.0)
17
+ rspec-support (~> 3.8.0)
18
+ rspec-expectations (3.8.3)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-mocks (3.8.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-support (3.8.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.17)
31
+ jet_black (~> 0.5)
32
+ rake (~> 10.0)
33
+ rspec (~> 3.8)
34
+ rspec-with_params!
35
+
36
+ BUNDLED WITH
37
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Oliver Peate
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,80 @@
1
+ # Rspec::WithParams
2
+
3
+ Simple parameterized testing with RSpec (a.k.a) table tests. Zero runtime
4
+ dependencies (well, you bring RSpec to the party).
5
+
6
+ ```ruby
7
+ RSpec.describe "my complex business logic" do
8
+ extend RSpec::WithParams::DSL
9
+
10
+ with_params(
11
+ [:today, :schedule, :expected_date],
12
+ ["2019-06-05", "weekly", "2019-06-13"],
13
+ ["2019-06-05", "bi-weekly", "2019-06-20"],
14
+ ["2019-06-05", "monthly", "2019-06-20"],
15
+ ) do
16
+ it "determines the next appointment date" do
17
+ result = NextAppointmentCalculator.new.process(today, schedule)
18
+ expect(result).to eq expected_date
19
+ end
20
+ end
21
+ end
22
+ ```
23
+
24
+ Output (with `--format documentation`):
25
+
26
+ ```
27
+ my complex business logic
28
+ given today -> "2019-06-05", schedule -> "weekly", expected_date -> "2019-06-13"
29
+ determines the next appointment date
30
+ given today -> "2019-06-05", schedule -> "monthly", expected_date -> "2019-06-20"
31
+ determines the next appointment date
32
+ given today -> "2019-06-05", schedule -> "bi-weekly", expected_date -> "2019-06-20"
33
+ determines the next appointment date
34
+
35
+ Finished in 0.00136 seconds (files took 0.12486 seconds to load)
36
+ 3 examples, 0 failures
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ruby
42
+ # Gemfile
43
+
44
+ group :test do
45
+ gem "rspec-with_params"
46
+ end
47
+ ```
48
+
49
+ Extend specific test groups:
50
+
51
+ ```ruby
52
+ require "rspec/with_params/dsl"
53
+
54
+ RSpec.describe "my complex business logic" do
55
+ extend RSpec::WithParams::DSL
56
+
57
+ # examples...
58
+ end
59
+ ```
60
+
61
+ Or configure RSpec globally:
62
+
63
+ ```ruby
64
+ require "rspec/with_params/dsl"
65
+
66
+ RSpec.configure do |config|
67
+ config.extend(RSpec::WithParams::DSL)
68
+ end
69
+ ```
70
+
71
+ ## Alternatives
72
+
73
+ - [`rspec-parameterized`][rspec-parameterized] - A more-complex, slicker DSL.
74
+ Inspiration for this library.
75
+
76
+ [rspec-parameterized]: https://github.com/tomykaira/rspec-parameterized
77
+
78
+ ## License
79
+
80
+ 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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/with_params"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ module RSpec
2
+ module WithParams
3
+ module DSL
4
+ def with_params(param_names, *parameter_groups, &block)
5
+ parameter_groups.each do |parameter_group|
6
+ params = param_names.zip(parameter_group)
7
+ test_case_description = params
8
+ .map { |name, value| "#{name} -> #{value.inspect}" }
9
+ .join(", ")
10
+
11
+ context("given #{test_case_description}") do
12
+ params.each do |name, value|
13
+ let(name) { value }
14
+ end
15
+
16
+ module_eval(&block)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module WithParams
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "rspec/with_params/version"
2
+
3
+ module RSpec
4
+ module WithParams
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "rspec/with_params/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rspec-with_params"
7
+ spec.version = RSpec::WithParams::VERSION
8
+ spec.authors = ["Oliver Peate"]
9
+
10
+ spec.summary = "Simple parameterized testing with RSpec (a.k.a table tests)"
11
+ spec.homepage = "https://github.com/odlp/rspec-with_params"
12
+ spec.license = "MIT"
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.17"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.8"
26
+ spec.add_development_dependency "jet_black", "~> 0.5"
27
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-with_params
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oliver Peate
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: jet_black
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.5'
69
+ description:
70
+ email:
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - ".rspec"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/rspec/with_params.rb
86
+ - lib/rspec/with_params/dsl.rb
87
+ - lib/rspec/with_params/version.rb
88
+ - rspec-with_params.gemspec
89
+ homepage: https://github.com/odlp/rspec-with_params
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.0.3
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Simple parameterized testing with RSpec (a.k.a table tests)
112
+ test_files: []