rspec-tabular 0.1.0 → 0.2.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 +4 -4
- data/.rubocop.yml +14 -0
- data/.travis.yml +22 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -0
- data/README.md +102 -4
- data/Rakefile +36 -3
- data/bin/console +1 -0
- data/lib/rspec/tabular.rb +112 -109
- data/lib/rspec/tabular/version.rb +3 -1
- data/rspec-tabular.gemspec +22 -6
- metadata +94 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee50d259d8af00fb9385f088ca5939d5bb822484
|
4
|
+
data.tar.gz: bd4ce1fc3fc7b2588687f09a6a4392dd8e030737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a841fd6aeaf03e823254bf19c35dbc1bcb1e90cfb1e72d52bbdc79d09e409520f8ecdc9411b211072d09ed1cbff31778adf95f90737faa3a6ce2b579fc6f92e
|
7
|
+
data.tar.gz: 4afad9b46e45f1d210d4c9c018e47f32bb055fe5ebc32eb6fb6e077f133462ceab2a58eaf7912d942e479b5e9a7c9f88b3a2b9b88cba2ecc5d3ec80aa03b056c
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,3 +1,24 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
3
|
+
- 2.1
|
4
|
+
- 2.2
|
5
|
+
- 2.3
|
6
|
+
- 2.4
|
7
|
+
- 2.5
|
8
|
+
- ruby-head
|
9
|
+
matrix:
|
10
|
+
allow_failures:
|
11
|
+
- rvm: ruby-head
|
12
|
+
- rvm: 2.4
|
13
|
+
os: osx
|
14
|
+
os:
|
15
|
+
- linux
|
16
|
+
- osx
|
17
|
+
sudo: false
|
18
|
+
before_script:
|
19
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter ; fi
|
20
|
+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter ; fi
|
21
|
+
- chmod +x ./cc-test-reporter
|
22
|
+
- ./cc-test-reporter before-build
|
23
|
+
after_script:
|
24
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## 0.0.2 - 2018-08-19
|
8
|
+
### Changed
|
9
|
+
- support checking Exception class and message in the same row
|
10
|
+
- catch exceptions when checking side effects, instead of raising the exception
|
11
|
+
|
12
|
+
## 0.0.1 - 2015-10-01
|
13
|
+
### Added
|
14
|
+
- Everything! This is the initial release with a lot of basic functionality.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# Rspec::Tabular
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/rspec-tabular)
|
4
|
-
[](https://gemnasium.com/sugarcrm/rspec-tabular)
|
5
4
|
[](https://travis-ci.org/sugarcrm/rspec-tabular)
|
6
|
-
[](https://coveralls.io/r/sugarcrm/rspec-tabular)
|
7
5
|
[](https://codeclimate.com/github/sugarcrm/rspec-tabular)
|
6
|
+
[](https://codeclimate.com/github/sugarcrm/rspec-tabular/coverage)
|
8
7
|
[](http://inch-ci.org/github/sugarcrm/rspec-tabular)
|
9
8
|
[](LICENSE)
|
10
9
|
|
@@ -28,7 +27,102 @@ Or install it yourself as:
|
|
28
27
|
|
29
28
|
## Usage
|
30
29
|
|
31
|
-
|
30
|
+
Here is an overall example using the rspec, followed by some more details of
|
31
|
+
the specified scenarios:
|
32
|
+
|
33
|
+
The input values which are specified are exposed as *let* values, so they can
|
34
|
+
be used in both the subject inputs or in stub/double expectations specified in
|
35
|
+
a before block.
|
36
|
+
|
37
|
+
```
|
38
|
+
describe '#thing' do
|
39
|
+
subject { subject.thing(input1, input2) }
|
40
|
+
before ( stub_model(ThingyModel, name: input3) }
|
41
|
+
|
42
|
+
let(:expected_value) { :expected_value }
|
43
|
+
|
44
|
+
inputs :input1, :input2, :input3
|
45
|
+
it_with 'value1', 'value2', 'value3', nil
|
46
|
+
it_with 'value4', 'value5', 'value6', true
|
47
|
+
it_with 'value7', 'value8', 'value9', 'foobar'
|
48
|
+
specify_with 'value1', 'value2', 'value3', 'foobar'
|
49
|
+
it_with( 'value1', 'value2', 'value3' ) { is_expected.to eq(expected_value) }
|
50
|
+
specify_with( 'value1', 'value2', 'value3' ) { expect(subject).to eq(expected_value) }
|
51
|
+
|
52
|
+
its_with :method, 'value1', 'value2', 'value3', 'something'
|
53
|
+
|
54
|
+
raise_error_with 'bad1', 'bad2', 'bad3', 'error'
|
55
|
+
raise_error_with 'bad4', 'bad5', 'bad6', TestException
|
56
|
+
raise_error_with 'bad4', 'bad5', 'bad6', TestException, 'error'
|
57
|
+
|
58
|
+
side_effects_with 'value4', 'value5', 'value6'
|
59
|
+
```
|
60
|
+
|
61
|
+
*specify_with* is an alias to *it_with*, therefore they both have the same
|
62
|
+
behaviour.
|
63
|
+
|
64
|
+
Please remember inputs or expected result values MUST be literal values, and cannot be
|
65
|
+
values memoized with let, because the let values are not evaluated soon enough.
|
66
|
+
You can use let values in the expectations if they are specified in a block.
|
67
|
+
(e.g., { is_expected.to eq(expected_value) })
|
68
|
+
|
69
|
+
|
70
|
+
### Equivalencies
|
71
|
+
|
72
|
+
Each of the tabular statements has an equivlanet non-tabular example to which
|
73
|
+
is corresponds.
|
74
|
+
|
75
|
+
```
|
76
|
+
it_with 'value1', 'value2', 'value3', nil
|
77
|
+
|
78
|
+
# Equivalent to:
|
79
|
+
context do
|
80
|
+
let(:input1) { 'value1' }
|
81
|
+
let(:input2) { 'value2' }
|
82
|
+
let(:input3) { 'value3' }
|
83
|
+
|
84
|
+
it { expected.to be_nil }
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
```
|
89
|
+
it_with( 'value1', 'value2', 'value3' ) { is_expected.to eq(expected_value) }
|
90
|
+
|
91
|
+
# Equivalent to:
|
92
|
+
context do
|
93
|
+
let(:input1) { 'value1' }
|
94
|
+
let(:input2) { 'value2' }
|
95
|
+
let(:input3) { 'value3' }
|
96
|
+
|
97
|
+
it { is_expected.to eq('expected') } }
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
```
|
102
|
+
raise_error_with 'bad4', 'bad5', 'bad6', TestException, 'error'
|
103
|
+
|
104
|
+
# Equivalent to:
|
105
|
+
context do
|
106
|
+
let(:input1) { 'bad4' }
|
107
|
+
let(:input2) { 'bad5' }
|
108
|
+
let(:input3) { 'bad6' }
|
109
|
+
|
110
|
+
specify { expect { subject }.to raise_error(TestException, 'error') }
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
```
|
115
|
+
side_effects_with 'value4', 'value5', 'value6'
|
116
|
+
|
117
|
+
# Equivalent to:
|
118
|
+
context do
|
119
|
+
let(:input1) { 'value4' }
|
120
|
+
let(:input2) { 'value5' }
|
121
|
+
let(:input3) { 'value6' }
|
122
|
+
|
123
|
+
specify { subject } }
|
124
|
+
end
|
125
|
+
```
|
32
126
|
|
33
127
|
## Development
|
34
128
|
|
@@ -38,8 +132,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
38
132
|
|
39
133
|
## Contributing
|
40
134
|
|
41
|
-
1. Fork it ( https://github.com/
|
135
|
+
1. Fork it ( https://github.com/sugarcrm/rspec-tabular/fork )
|
42
136
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
137
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
138
|
4. Push to the branch (`git push origin my-new-feature`)
|
45
139
|
5. Create a new Pull Request
|
140
|
+
|
141
|
+
## License
|
142
|
+
|
143
|
+
Copyright 2015 [SugarCRM Inc.](http://sugarcrm.com), released under the Apache2 License.
|
data/Rakefile
CHANGED
@@ -1,7 +1,40 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'bundler/gem_tasks'
|
3
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'bundler/audit/task'
|
7
|
+
require 'pathname'
|
8
|
+
require 'license_finder'
|
9
|
+
require 'English'
|
10
|
+
|
11
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
12
|
+
task.rspec_opts = '--warnings'
|
13
|
+
end
|
14
|
+
|
15
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
16
|
+
rubocop_report_pathname =
|
17
|
+
Pathname(Rake.application.original_dir).join('tmp', 'rubocop.txt')
|
18
|
+
rubocop_report_pathname.dirname.mkpath
|
19
|
+
task.requires << 'rubocop-rspec'
|
20
|
+
task.options =
|
21
|
+
%w[
|
22
|
+
--display-cop-names
|
23
|
+
--extra-details
|
24
|
+
--display-style-guide
|
25
|
+
--fail-level error
|
26
|
+
--format progress
|
27
|
+
--format simple --out
|
28
|
+
].push(rubocop_report_pathname.to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
Bundler::Audit::Task.new
|
32
|
+
|
33
|
+
desc 'Check dependency licenses'
|
34
|
+
task :license_finder do
|
35
|
+
puts `license_finder --quiet --format text`
|
4
36
|
|
5
|
-
|
37
|
+
abort('LicenseFinder failed') unless $CHILD_STATUS.success?
|
38
|
+
end
|
6
39
|
|
7
|
-
task default: :
|
40
|
+
task default: %i[spec rubocop bundle:audit license_finder]
|
data/bin/console
CHANGED
data/lib/rspec/tabular.rb
CHANGED
@@ -1,122 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rspec/tabular/version'
|
2
4
|
|
3
|
-
# This module will allow examples to be specified in a more clean tabular
|
4
|
-
# manner.
|
5
|
-
#
|
6
|
-
# The same tests can be executed using standard lets, context and examples
|
7
|
-
# but this will streamline how they are expressed. An example of this is:
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# describe 'a thing' do
|
11
|
-
# context { let(:input1) { 'value1' } ; let(:input2) { 'value2' } ; let(:input3) { 'value3' } ; it { should be false } }
|
12
|
-
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; it { should be true } }
|
13
|
-
# context { let(:input1) { 'value7' } ; let(:input2) { 'value8' } ; let(:input3) { 'value9' } ; it { should eq('foobar') } }
|
14
|
-
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; its(:method) { should eq('something') } }
|
15
|
-
# context { let(:input1) { 'bad1' } ; let(:input2) { 'bad2' } ; let(:input3) { 'bad3' } ; specify { expect { subject }.to raise_error('error') }
|
16
|
-
# context { let(:input1) { 'bad4' } ; let(:input2) { 'bad5' } ; let(:input3) { 'bad6' } ; specify { expect { subject }.to raise_error(TestException) }
|
17
|
-
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; specify { helper_method.should eq('expected') } }
|
18
|
-
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; specify { subject } }
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# Which works but is not very DRY, and has a great deal of boiler plate code.
|
22
|
-
# This module can improve that with the following helper methods:
|
23
|
-
#
|
24
|
-
# * inputs - defines the list of values for the example
|
25
|
-
# * it_with
|
26
|
-
# * its_with
|
27
|
-
# * raise_error_with
|
28
|
-
# * specify_with
|
29
|
-
# * side_effects_with - like specify_with but assumes a block of '{ subject }'
|
30
|
-
#
|
31
|
-
# Limitations:
|
32
|
-
# - inputs can only be simple types, and cannot use values defined by let
|
33
|
-
#
|
34
|
-
# @example
|
35
|
-
# describe 'a thing with explicit blocks' do
|
36
|
-
# subject { subject.thing(input1, input2) }
|
37
|
-
# before ( stub_model(ThingyModel, name: input3) }
|
38
|
-
#
|
39
|
-
# inputs( :input1, :input2, :input3)
|
40
|
-
# it_with( 'value1', 'value2', 'value3') { should be false }
|
41
|
-
# it_with( 'value4', 'value5', 'value6') { should be true }
|
42
|
-
# it_with( 'value4', 'value5', 'value6') { should eq('foobar') }
|
43
|
-
#
|
44
|
-
# its_with(:method, 'value4', 'value5', 'value6') { should eq('something') }
|
45
|
-
#
|
46
|
-
# specify( 'value1', 'value2', 'value3' ) { helper_method.should eq('expected')
|
47
|
-
# end
|
48
|
-
#
|
49
|
-
# describe 'a thing with implicit shoulds' do
|
50
|
-
# subject { subject.thing(input1, input2) }
|
51
|
-
# before ( stub_model(ThingyModel, name: input3) }
|
52
|
-
#
|
53
|
-
# inputs :input1, :input2, :input3
|
54
|
-
# it_with 'value1', 'value2', 'value3', nil
|
55
|
-
# it_with 'value4', 'value5', 'value6', true
|
56
|
-
# it_with 'value7', 'value8', 'value9', 'foobar'
|
57
|
-
#
|
58
|
-
# its_with :method, 'value1', 'value2', 'value3', 'something'
|
59
|
-
#
|
60
|
-
# raise_error_with 'bad1', 'bad2', 'bad3', 'error'
|
61
|
-
# raise_error_with 'bad4', 'bad5', 'bad6', TestException
|
62
|
-
#
|
63
|
-
# side_effects_with 'value4', 'value5', 'value6'
|
64
|
-
# end
|
65
|
-
#
|
66
|
-
# Inputs can also be specified as block arguments. I am not sure if this is
|
67
|
-
# really useful, it might be deprecated in the future.
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
# describe 'a thing', :inputs => [:input1, :input2, :input3] do
|
71
|
-
# subject { subject.thing(input1, input2) }
|
72
|
-
# before ( stub_model(ThingyModel, name: input3) }
|
73
|
-
#
|
74
|
-
# it_with('value1', 'value2', 'value3') { should be false }
|
75
|
-
# end
|
76
5
|
module Rspec
|
6
|
+
# rubocop:disable all
|
7
|
+
|
8
|
+
# This module will allow examples to be specified in a more clean tabular
|
9
|
+
# manner.
|
10
|
+
#
|
11
|
+
# The same tests can be executed using standard lets, context and examples
|
12
|
+
# but this will streamline how they are expressed. An example of this is:
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# describe 'a thing' do
|
16
|
+
# context { let(:input1) { 'value1' } ; let(:input2) { 'value2' } ; let(:input3) { 'value3' } ; it { should be false } }
|
17
|
+
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; it { should be true } }
|
18
|
+
# context { let(:input1) { 'value7' } ; let(:input2) { 'value8' } ; let(:input3) { 'value9' } ; it { should eq('foobar') } }
|
19
|
+
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; its(:method) { should eq('something') } }
|
20
|
+
# context { let(:input1) { 'bad1' } ; let(:input2) { 'bad2' } ; let(:input3) { 'bad3' } ; specify { expect { subject }.to raise_error('error') }
|
21
|
+
# context { let(:input1) { 'bad4' } ; let(:input2) { 'bad5' } ; let(:input3) { 'bad6' } ; specify { expect { subject }.to raise_error(TestException) }
|
22
|
+
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; specify { helper_method.should eq('expected') } }
|
23
|
+
# context { let(:input1) { 'value4' } ; let(:input2) { 'value5' } ; let(:input3) { 'value6' } ; specify { subject } }
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Which works but is not very DRY, and has a great deal of boiler plate code.
|
27
|
+
# This module can improve that with the following helper methods:
|
28
|
+
#
|
29
|
+
# * inputs - defines the list of values for the example
|
30
|
+
# * it_with
|
31
|
+
# * its_with
|
32
|
+
# * raise_error_with
|
33
|
+
# * specify_with
|
34
|
+
# * side_effects_with - like specify_with but assumes a block of '{ subject }'
|
35
|
+
#
|
36
|
+
# Limitations:
|
37
|
+
# - inputs can only be simple types, and cannot use values defined by let
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# describe 'a thing with explicit blocks' do
|
41
|
+
# subject { subject.thing(input1, input2) }
|
42
|
+
# before ( stub_model(ThingyModel, name: input3) }
|
43
|
+
#
|
44
|
+
# inputs( :input1, :input2, :input3)
|
45
|
+
# it_with( 'value1', 'value2', 'value3') { should be false }
|
46
|
+
# it_with( 'value4', 'value5', 'value6') { should be true }
|
47
|
+
# it_with( 'value4', 'value5', 'value6') { should eq('foobar') }
|
48
|
+
#
|
49
|
+
# its_with(:method, 'value4', 'value5', 'value6') { should eq('something') }
|
50
|
+
#
|
51
|
+
# specify_with( 'value1', 'value2', 'value3' ) { helper_method.should eq('expected') }
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# describe 'a thing with implicit shoulds' do
|
55
|
+
# subject { subject.thing(input1, input2) }
|
56
|
+
# before ( stub_model(ThingyModel, name: input3) }
|
57
|
+
#
|
58
|
+
# inputs :input1, :input2, :input3
|
59
|
+
# it_with 'value1', 'value2', 'value3', nil
|
60
|
+
# it_with 'value4', 'value5', 'value6', true
|
61
|
+
# it_with 'value7', 'value8', 'value9', 'foobar'
|
62
|
+
#
|
63
|
+
# its_with :method, 'value1', 'value2', 'value3', 'something'
|
64
|
+
#
|
65
|
+
# raise_error_with 'bad1', 'bad2', 'bad3', 'error'
|
66
|
+
# raise_error_with 'bad4', 'bad5', 'bad6', TestException
|
67
|
+
# raise_error_with 'bad4', 'bad5', 'bad6', TestException, 'error'
|
68
|
+
#
|
69
|
+
# side_effects_with 'value4', 'value5', 'value6'
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# Inputs can also be specified as block arguments. I am not sure if this is
|
73
|
+
# really useful, it might be deprecated in the future.
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# describe 'a thing', :inputs => [:input1, :input2, :input3] do
|
77
|
+
# subject { subject.thing(input1, input2) }
|
78
|
+
# before ( stub_model(ThingyModel, name: input3) }
|
79
|
+
#
|
80
|
+
# it_with('value1', 'value2', 'value3') { should be false }
|
81
|
+
# end
|
82
|
+
|
83
|
+
# rubocop:enable all
|
77
84
|
module Tabular
|
78
85
|
def inputs(*args)
|
79
86
|
metadata[:inputs] ||= args
|
80
87
|
end
|
81
88
|
|
82
|
-
# Alias for it_with
|
83
|
-
def specify_with(*args, &block)
|
84
|
-
it_with(*args, &block)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Example with an implicit subject execution
|
88
|
-
def side_effects_with(*args)
|
89
|
-
it_with(*args) { subject }
|
90
|
-
end
|
91
|
-
|
92
|
-
def raise_error_with(*args, expected_exception)
|
93
|
-
it_with(*args) { expect { subject }.to raise_error(expected_exception) }
|
94
|
-
end
|
95
|
-
|
96
89
|
def it_with(*input_values, &block)
|
97
90
|
if block.nil? && (metadata[:inputs].size == input_values.size - 1)
|
98
91
|
expected_value = input_values.pop
|
99
|
-
block =
|
100
|
-
if expected_value.nil?
|
101
|
-
proc { should be_nil }
|
102
|
-
elsif expected_value.is_a?(TrueClass) || expected_value.is_a?(FalseClass)
|
103
|
-
proc { is_expected.to be expected_value }
|
104
|
-
else
|
105
|
-
proc { should eq(expected_value) }
|
106
|
-
end
|
92
|
+
block = proc { is_expected.to eq(expected_value) }
|
107
93
|
end
|
108
94
|
|
109
95
|
context("with #{Hash[metadata[:inputs].zip input_values]}") do
|
110
|
-
def should(matcher = nil, message = nil)
|
111
|
-
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
|
112
|
-
end
|
113
|
-
|
114
|
-
def should_not(matcher = nil, message = nil)
|
115
|
-
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
|
116
|
-
end
|
117
|
-
|
118
96
|
metadata[:inputs].each_index do |i|
|
119
|
-
key
|
97
|
+
key = metadata[:inputs][i]
|
120
98
|
let(key) { input_values[i] }
|
121
99
|
end
|
122
100
|
|
@@ -124,6 +102,27 @@ module Rspec
|
|
124
102
|
end
|
125
103
|
end
|
126
104
|
|
105
|
+
alias specify_with it_with
|
106
|
+
|
107
|
+
# Example with an implicit subject execution
|
108
|
+
def side_effects_with(*args)
|
109
|
+
it_with(*args) do
|
110
|
+
begin
|
111
|
+
subject
|
112
|
+
rescue Exception # rubocop:disable Lint/HandleExceptions, Lint/RescueException
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def raise_error_with(*args)
|
118
|
+
raise_error_args = args
|
119
|
+
it_with_args = raise_error_args.slice!(0, metadata[:inputs].size)
|
120
|
+
|
121
|
+
it_with(*it_with_args) do
|
122
|
+
expect { subject }.to raise_error(*raise_error_args)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
127
126
|
def its_with(attribute, *input_values, &block)
|
128
127
|
if block.nil? && (metadata[:inputs].size == input_values.size - 1)
|
129
128
|
expected_value = input_values.pop
|
@@ -142,16 +141,20 @@ module Rspec
|
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
145
|
-
def should(matcher = nil, message = nil)
|
146
|
-
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(
|
144
|
+
def should(matcher = nil, message = nil) # rubocop:disable Lint/NestedMethodDefinition
|
145
|
+
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(
|
146
|
+
__its_subject, matcher, message
|
147
|
+
)
|
147
148
|
end
|
148
149
|
|
149
|
-
def should_not(matcher = nil, message = nil)
|
150
|
-
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(
|
150
|
+
def should_not(matcher = nil, message = nil) # rubocop:disable Lint/NestedMethodDefinition
|
151
|
+
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(
|
152
|
+
__its_subject, matcher, message
|
153
|
+
)
|
151
154
|
end
|
152
155
|
|
153
156
|
metadata[:inputs].each_index do |i|
|
154
|
-
key
|
157
|
+
key = metadata[:inputs][i]
|
155
158
|
let(key) { input_values[i] }
|
156
159
|
end
|
157
160
|
|
data/rspec-tabular.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'rspec/tabular/version'
|
5
6
|
|
@@ -9,16 +10,31 @@ Gem::Specification.new do |spec|
|
|
9
10
|
spec.authors = ['Andrew Sullivan Cant']
|
10
11
|
spec.email = ['acant@sugarcrm.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
13
|
+
spec.summary = 'RSpec extension for writing tabular examples.'
|
14
|
+
spec.description = 'RSpec DSL which makes is easier and cleaner to write tabular examples.'
|
14
15
|
spec.homepage = 'http://github.com/sugarcrm/rspec-tabular'
|
16
|
+
spec.license = 'Apache-2.0'
|
15
17
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
23
|
spec.require_paths = ['lib']
|
19
24
|
|
25
|
+
spec.required_ruby_version = '>= 2.1.0'
|
26
|
+
|
20
27
|
spec.add_runtime_dependency 'rspec-core', '>= 2.99.0'
|
21
|
-
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
31
|
spec.add_development_dependency 'rspec', '~> 2.99.0'
|
32
|
+
|
33
|
+
# Dependencies whose APIs we do not really depend upon, and can be upgraded
|
34
|
+
# without limiting.
|
35
|
+
spec.add_development_dependency 'bundler-audit'
|
36
|
+
spec.add_development_dependency 'license_finder'
|
37
|
+
spec.add_development_dependency 'rubocop'
|
38
|
+
spec.add_development_dependency 'rubocop-rspec'
|
39
|
+
spec.add_development_dependency 'simplecov'
|
24
40
|
end
|
metadata
CHANGED
@@ -1,71 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-tabular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Sullivan Cant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.99.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.99.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.99.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.99.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler-audit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: license_finder
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
69
139
|
description: RSpec DSL which makes is easier and cleaner to write tabular examples.
|
70
140
|
email:
|
71
141
|
- acant@sugarcrm.com
|
@@ -73,20 +143,24 @@ executables: []
|
|
73
143
|
extensions: []
|
74
144
|
extra_rdoc_files: []
|
75
145
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".rubocop.yml"
|
149
|
+
- ".travis.yml"
|
150
|
+
- CHANGELOG.md
|
79
151
|
- Gemfile
|
80
152
|
- LICENSE
|
81
153
|
- README.md
|
82
154
|
- Rakefile
|
83
155
|
- bin/console
|
84
156
|
- bin/setup
|
157
|
+
- doc/dependency_decisions.yml
|
85
158
|
- lib/rspec/tabular.rb
|
86
159
|
- lib/rspec/tabular/version.rb
|
87
160
|
- rspec-tabular.gemspec
|
88
161
|
homepage: http://github.com/sugarcrm/rspec-tabular
|
89
|
-
licenses:
|
162
|
+
licenses:
|
163
|
+
- Apache-2.0
|
90
164
|
metadata: {}
|
91
165
|
post_install_message:
|
92
166
|
rdoc_options: []
|
@@ -94,17 +168,17 @@ require_paths:
|
|
94
168
|
- lib
|
95
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
170
|
requirements:
|
97
|
-
- -
|
171
|
+
- - ">="
|
98
172
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
173
|
+
version: 2.1.0
|
100
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
175
|
requirements:
|
102
|
-
- -
|
176
|
+
- - ">="
|
103
177
|
- !ruby/object:Gem::Version
|
104
178
|
version: '0'
|
105
179
|
requirements: []
|
106
180
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.6.11
|
108
182
|
signing_key:
|
109
183
|
specification_version: 4
|
110
184
|
summary: RSpec extension for writing tabular examples.
|