rspec-parameterized 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/lib/rspec-parameterized.rb +1 -0
- data/lib/rspec/parameterized.rb +54 -0
- data/lib/rspec/parameterized/version.rb +5 -0
- data/rspec-parameterized.gemspec +21 -0
- data/spec/parametarized_spec.rb +37 -0
- data/spec/spec_helper.rb +7 -0
- metadata +98 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 tomykaira
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# RSpec::Parameterized
|
2
|
+
|
3
|
+
Support simple parameterized test syntax in rspec.
|
4
|
+
|
5
|
+
describe "plus" do
|
6
|
+
where(:a, :b, :answer) do
|
7
|
+
[
|
8
|
+
[1 , 2 , 3],
|
9
|
+
[5 , 8 , 13],
|
10
|
+
[0 , 0 , 0]
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
with_them do
|
15
|
+
it "should do additions" do
|
16
|
+
(a + b).should == answer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
I was inspired by [udzura's mock](https://gist.github.com/1881139).
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
gem 'rspec-parameterized'
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install rspec-parameterized
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
Require `rspec-parameterized` from your `spec_helper.rb`.
|
40
|
+
|
41
|
+
require 'rspec-parameterized'
|
42
|
+
|
43
|
+
Follow the sample spec above.
|
44
|
+
|
45
|
+
Arguments given to `with_them` is directly passed to `describe`. You can specify `:pending`, `:focus`, etc. here.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/parameterized'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "rspec/parameterized/version"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Parameterized
|
5
|
+
module ExampleGroupMethods
|
6
|
+
|
7
|
+
# Set parameters to be bound in specs under this example group.
|
8
|
+
#
|
9
|
+
# ## Example
|
10
|
+
#
|
11
|
+
# where(:a, :b, :answer) do
|
12
|
+
# [
|
13
|
+
# [1 , 2 , 3],
|
14
|
+
# [5 , 8 , 13],
|
15
|
+
# [0 , 0 , 0]
|
16
|
+
# ]
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
def where(*args, &b)
|
20
|
+
@arg_names = args
|
21
|
+
@param_sets = b.call
|
22
|
+
end
|
23
|
+
|
24
|
+
# Use parameters to execute the block.
|
25
|
+
# The given block is converted into +describe+s for each parameter set.
|
26
|
+
#
|
27
|
+
# ## Example
|
28
|
+
# with_them do
|
29
|
+
# it "should do additions" do
|
30
|
+
# (a + b).should == answer
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
def with_them(*args, &block)
|
35
|
+
arg_names = @arg_names
|
36
|
+
@param_sets.each do |params|
|
37
|
+
describe(params.inspect, *args) do
|
38
|
+
[arg_names, params].transpose.each do |n|
|
39
|
+
let(n[0]) { n[1] }
|
40
|
+
end
|
41
|
+
|
42
|
+
module_eval(&block)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module Core
|
50
|
+
class ExampleGroup
|
51
|
+
extend ::RSpec::Parameterized::ExampleGroupMethods
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rspec/parameterized/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["tomykaira"]
|
6
|
+
gem.email = ["tomykaira@gmail.com"]
|
7
|
+
gem.description = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.}
|
8
|
+
gem.summary = %q{RSpec::Parameterized supports simple parameterized test syntax in rspec.
|
9
|
+
I was inspired by [udzura's mock](https://gist.github.com/1881139).}
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.add_dependency('rspec', '~>2.10.0')
|
13
|
+
gem.add_development_dependency('rake')
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.name = "rspec-parameterized"
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
gem.version = RSpec::Parameterized::VERSION
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
# RSpec::Parameterized
|
4
|
+
# Sample
|
5
|
+
# plus
|
6
|
+
# [1, 2, 3]
|
7
|
+
# should do additions
|
8
|
+
# [5, 8, 13]
|
9
|
+
# should do additions
|
10
|
+
# [0, 0, 0]
|
11
|
+
# should do additions
|
12
|
+
|
13
|
+
describe RSpec::Parameterized do
|
14
|
+
describe "Sample" do
|
15
|
+
describe "plus" do
|
16
|
+
where(:a, :b, :answer) do
|
17
|
+
[
|
18
|
+
[1 , 2 , 3],
|
19
|
+
[5 , 8 , 13],
|
20
|
+
[0 , 0 , 0]
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
with_them do
|
25
|
+
it "should do additions" do
|
26
|
+
(a + b).should == answer
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
with_them :pending do
|
31
|
+
it "should do additions" do
|
32
|
+
(a + b).should == answer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-parameterized
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- tomykaira
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.10.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.10.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: RSpec::Parameterized supports simple parameterized test syntax in rspec.
|
47
|
+
email:
|
48
|
+
- tomykaira@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .rspec
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/rspec-parameterized.rb
|
60
|
+
- lib/rspec/parameterized.rb
|
61
|
+
- lib/rspec/parameterized/version.rb
|
62
|
+
- rspec-parameterized.gemspec
|
63
|
+
- spec/parametarized_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: ''
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: -316469805
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
hash: -316469805
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.8.24
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: RSpec::Parameterized supports simple parameterized test syntax in rspec.
|
95
|
+
I was inspired by [udzura's mock](https://gist.github.com/1881139).
|
96
|
+
test_files:
|
97
|
+
- spec/parametarized_spec.rb
|
98
|
+
- spec/spec_helper.rb
|