specify 0.10.0 → 0.10.2
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/.gitignore +23 -10
- data/.hound.yml +95 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +18 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +0 -4
- data/LICENSE.txt +1 -1
- data/README.md +11 -6
- data/Rakefile +13 -2
- data/bin/console +10 -0
- data/bin/setup +5 -0
- data/lib/specify/rspec/documentation_formatter.rb +3 -4
- data/lib/specify/rspec/example_group.rb +6 -8
- data/lib/specify/rspec/notification.rb +2 -3
- data/lib/specify/rspec/reporter.rb +0 -1
- data/lib/specify/rspec/shared_steps.rb +5 -3
- data/lib/specify/rspec/world.rb +0 -1
- data/lib/specify/version.rb +1 -1
- data/lib/specify.rb +10 -12
- data/specify.gemspec +9 -12
- metadata +22 -61
- data/lib/specify/rspec/parameterized.rb +0 -138
- data/lib/specify/rspec/table.rb +0 -54
- data/lib/specify/rspec/tabular.rb +0 -45
- data/spec/api_spec.rb +0 -45
- data/spec/parameterized_spec.rb +0 -229
- data/spec/pending_spec.rb +0 -12
- data/spec/shared_steps_spec.rb +0 -92
- data/spec/spec_helper.rb +0 -18
- data/spec/steps_spec.rb +0 -83
- data/spec/top_level_spec.rb +0 -16
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,40 +40,12 @@ dependencies:
|
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.1'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-core
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.1'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: parser
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - ">="
|
74
46
|
- !ruby/object:Gem::Version
|
75
47
|
version: '0'
|
76
|
-
type: :
|
48
|
+
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
@@ -81,13 +53,13 @@ dependencies:
|
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
56
|
+
name: pry
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - ">="
|
88
60
|
- !ruby/object:Gem::Version
|
89
61
|
version: '0'
|
90
|
-
type: :
|
62
|
+
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
@@ -95,13 +67,13 @@ dependencies:
|
|
95
67
|
- !ruby/object:Gem::Version
|
96
68
|
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
70
|
+
name: simplecov
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
73
|
- - ">="
|
102
74
|
- !ruby/object:Gem::Version
|
103
75
|
version: '0'
|
104
|
-
type: :
|
76
|
+
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
@@ -109,13 +81,13 @@ dependencies:
|
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
84
|
+
name: rubocop
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
87
|
- - ">="
|
116
88
|
- !ruby/object:Gem::Version
|
117
89
|
version: '0'
|
118
|
-
type: :
|
90
|
+
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
93
|
requirements:
|
@@ -133,36 +105,32 @@ extensions: []
|
|
133
105
|
extra_rdoc_files: []
|
134
106
|
files:
|
135
107
|
- ".gitignore"
|
108
|
+
- ".hound.yml"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".travis.yml"
|
111
|
+
- CODE_OF_CONDUCT.md
|
136
112
|
- Gemfile
|
137
113
|
- LICENSE.txt
|
138
114
|
- README.md
|
139
115
|
- Rakefile
|
116
|
+
- bin/console
|
117
|
+
- bin/setup
|
140
118
|
- lib/specify.rb
|
141
119
|
- lib/specify/rspec/documentation_formatter.rb
|
142
120
|
- lib/specify/rspec/example_group.rb
|
143
121
|
- lib/specify/rspec/notification.rb
|
144
|
-
- lib/specify/rspec/parameterized.rb
|
145
122
|
- lib/specify/rspec/reporter.rb
|
146
123
|
- lib/specify/rspec/shared_steps.rb
|
147
|
-
- lib/specify/rspec/table.rb
|
148
|
-
- lib/specify/rspec/tabular.rb
|
149
124
|
- lib/specify/rspec/world.rb
|
150
125
|
- lib/specify/spec.rb
|
151
126
|
- lib/specify/version.rb
|
152
|
-
- spec/api_spec.rb
|
153
|
-
- spec/parameterized_spec.rb
|
154
|
-
- spec/pending_spec.rb
|
155
|
-
- spec/shared_steps_spec.rb
|
156
|
-
- spec/spec_helper.rb
|
157
|
-
- spec/steps_spec.rb
|
158
|
-
- spec/top_level_spec.rb
|
159
127
|
- specify.gemspec
|
160
128
|
homepage: https://github.com/jnyman/specify
|
161
129
|
licenses:
|
162
130
|
- MIT
|
163
131
|
metadata: {}
|
164
132
|
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n
|
165
|
-
\ Specify 0.10.
|
133
|
+
\ Specify 0.10.2 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
|
166
134
|
(::) (::) (::) (::)\n "
|
167
135
|
rdoc_options: []
|
168
136
|
require_paths:
|
@@ -171,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
139
|
requirements:
|
172
140
|
- - ">="
|
173
141
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.0
|
142
|
+
version: '2.0'
|
175
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
144
|
requirements:
|
177
145
|
- - ">="
|
@@ -179,15 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
147
|
version: 1.8.29
|
180
148
|
requirements: []
|
181
149
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.4.5.1
|
183
151
|
signing_key:
|
184
152
|
specification_version: 4
|
185
153
|
summary: Description Language Specification and Execution Engine
|
186
|
-
test_files:
|
187
|
-
- spec/api_spec.rb
|
188
|
-
- spec/parameterized_spec.rb
|
189
|
-
- spec/pending_spec.rb
|
190
|
-
- spec/shared_steps_spec.rb
|
191
|
-
- spec/spec_helper.rb
|
192
|
-
- spec/steps_spec.rb
|
193
|
-
- spec/top_level_spec.rb
|
154
|
+
test_files: []
|
@@ -1,138 +0,0 @@
|
|
1
|
-
require 'parser'
|
2
|
-
require 'unparser'
|
3
|
-
require 'proc_to_ast'
|
4
|
-
|
5
|
-
module RSpec
|
6
|
-
module Specify
|
7
|
-
module Parameterized
|
8
|
-
autoload :Tabular, 'specify/rspec/tabular'
|
9
|
-
|
10
|
-
module ExampleGroupMethods
|
11
|
-
class Parameter
|
12
|
-
attr_reader :arg_names, :table_format, :block
|
13
|
-
|
14
|
-
def initialize(arg_names, table_format, &block)
|
15
|
-
@arg_names, @table_format, @block = arg_names, table_format, block
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def data_condition(*args, &block)
|
20
|
-
set_parameters(args, false, &block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def data_table(*args, &block)
|
24
|
-
set_parameters(args, true, &block)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_condition(*args, &block)
|
28
|
-
if @parameter.nil?
|
29
|
-
@parameterized_pending_cases ||= []
|
30
|
-
@parameterized_pending_cases << [args, block]
|
31
|
-
else
|
32
|
-
define_cases(@parameter, *args, &block)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
alias_method :where, :data_condition
|
37
|
-
alias_method :where_table, :data_table
|
38
|
-
alias_method :with_those, :test_condition
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def set_parameters(arg_names, table_format, &block)
|
43
|
-
@parameter = Parameter.new(arg_names, table_format, &block)
|
44
|
-
|
45
|
-
if @parameterized_pending_cases
|
46
|
-
@parameterized_pending_cases.each { |e|
|
47
|
-
define_cases(@parameter, *e[0], &e[1])
|
48
|
-
}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def separate_table_like_block(b)
|
53
|
-
ast = b.to_ast
|
54
|
-
inner_ast = ast.children[2]
|
55
|
-
if inner_ast.type == :send
|
56
|
-
lines = [inner_ast]
|
57
|
-
else
|
58
|
-
lines = inner_ast.children
|
59
|
-
end
|
60
|
-
|
61
|
-
lines.map do |node|
|
62
|
-
if node.type == :send
|
63
|
-
buf = []
|
64
|
-
extract_value(node, buf)
|
65
|
-
buf.reverse
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def extract_value(node, buf)
|
71
|
-
receiver, method, arg = node.children
|
72
|
-
|
73
|
-
if method == :|
|
74
|
-
buf << eval_source_fragment(Unparser.unparse(arg))
|
75
|
-
end
|
76
|
-
|
77
|
-
if receiver.is_a?(AST::Node) && receiver.type == :send && receiver.children[1] == :|
|
78
|
-
extract_value(receiver, buf)
|
79
|
-
else
|
80
|
-
buf << eval_source_fragment(Unparser.unparse(receiver))
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def eval_source_fragment(source_fragment)
|
85
|
-
instance = new # for evaluate let methods.
|
86
|
-
if defined?(self.superclass::LetDefinitions)
|
87
|
-
instance.extend self.superclass::LetDefinitions
|
88
|
-
end
|
89
|
-
instance.instance_eval(source_fragment)
|
90
|
-
end
|
91
|
-
|
92
|
-
def define_cases(parameter, *args, &block)
|
93
|
-
instance = new # for evaluate let methods
|
94
|
-
if defined?(self.superclass::LetDefinitions)
|
95
|
-
instance.extend self.superclass::LetDefinitions
|
96
|
-
end
|
97
|
-
|
98
|
-
if parameter.table_format
|
99
|
-
param_sets = separate_table_like_block(parameter.block)
|
100
|
-
else
|
101
|
-
extracted = instance.instance_eval(¶meter.block)
|
102
|
-
param_sets = extracted.is_a?(Array) ? extracted : extracted.to_params
|
103
|
-
end
|
104
|
-
|
105
|
-
# for only one parameter
|
106
|
-
param_sets = param_sets.map { |x| Array[x] } if !param_sets[0].is_a?(Array)
|
107
|
-
|
108
|
-
param_sets.each do |params|
|
109
|
-
pairs = [parameter.arg_names, params].transpose
|
110
|
-
pretty_params = pairs.map {|t| "#{t[0]}: #{params_inspect(t[1])}"}.join(', ')
|
111
|
-
describe(pretty_params, *args) do
|
112
|
-
pairs.each do |n|
|
113
|
-
let(n[0]) { n[1] }
|
114
|
-
end
|
115
|
-
|
116
|
-
module_eval(&block)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def params_inspect(obj)
|
122
|
-
begin
|
123
|
-
obj.is_a?(Proc) ? obj.to_raw_source : obj.inspect
|
124
|
-
#rescue Parser::SyntaxError
|
125
|
-
# return obj.inspect
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
module Core
|
134
|
-
class ExampleGroup
|
135
|
-
extend ::RSpec::Specify::Parameterized::ExampleGroupMethods
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
data/lib/specify/rspec/table.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Specify
|
3
|
-
module Parameterized
|
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
|
-
|
25
|
-
alias :| :add_param_to_last_row
|
26
|
-
|
27
|
-
def to_a
|
28
|
-
@rows.map(&:to_a)
|
29
|
-
end
|
30
|
-
|
31
|
-
alias :to_params :to_a
|
32
|
-
|
33
|
-
class Row
|
34
|
-
def initialize(param)
|
35
|
-
@params = [param]
|
36
|
-
end
|
37
|
-
|
38
|
-
def add_param(param)
|
39
|
-
@params << param
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_a
|
43
|
-
@params
|
44
|
-
end
|
45
|
-
|
46
|
-
#def to_params
|
47
|
-
# [@params]
|
48
|
-
#end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'binding_of_caller'
|
2
|
-
require 'specify/rspec/table'
|
3
|
-
|
4
|
-
module RSpec
|
5
|
-
module Specify
|
6
|
-
module Parameterized
|
7
|
-
module TabularSyntax
|
8
|
-
def |(other)
|
9
|
-
where_binding = binding.of_caller(1) # get where block binding
|
10
|
-
caller_instance = eval('self', where_binding) # get caller instance (ExampleGroup)
|
11
|
-
|
12
|
-
if caller_instance.instance_variable_defined?(:@__parameter_table)
|
13
|
-
table = caller_instance.instance_variable_get(:@__parameter_table)
|
14
|
-
else
|
15
|
-
table = RSpec::Specify::Parameterized::Table.new
|
16
|
-
caller_instance.instance_variable_set(:@__parameter_table, table)
|
17
|
-
end
|
18
|
-
|
19
|
-
row = Table::Row.new(self)
|
20
|
-
table.add_row(row)
|
21
|
-
row.add_param(other)
|
22
|
-
table
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
module Tabular
|
27
|
-
refine Object do
|
28
|
-
include TabularSyntax
|
29
|
-
end
|
30
|
-
|
31
|
-
refine Fixnum do
|
32
|
-
include TabularSyntax
|
33
|
-
end
|
34
|
-
|
35
|
-
refine Bignum do
|
36
|
-
include TabularSyntax
|
37
|
-
end
|
38
|
-
|
39
|
-
refine Array do
|
40
|
-
include TabularSyntax
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/api_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
Component 'component block' do
|
4
|
-
steps 'steps block' do
|
5
|
-
step 'step block' do
|
6
|
-
@result = 'result'
|
7
|
-
expect(@result).to eq('result')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Step 'step block' do
|
12
|
-
step 'step block' do
|
13
|
-
@result = 'result'
|
14
|
-
expect(@result).to eq('result')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
tests 'tests block' do
|
19
|
-
test 'test block' do
|
20
|
-
@result = 'result'
|
21
|
-
expect(@result).to eq('result')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
Test 'test block' do
|
26
|
-
test 'test block' do
|
27
|
-
@result = 'result'
|
28
|
-
expect(@result).to eq('result')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
rules 'rules block' do
|
33
|
-
rule 'rule block' do
|
34
|
-
@result = 'result'
|
35
|
-
expect(@result).to eq('result')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
Rule 'rule block' do
|
40
|
-
rule 'rule block' do
|
41
|
-
@result = 'result'
|
42
|
-
expect(@result).to eq('result')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/parameterized_spec.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RSpec::Specify::Parameterized do
|
4
|
-
describe 'data_condition' do
|
5
|
-
data_condition(:a, :b, :answer) do
|
6
|
-
[
|
7
|
-
[1, 2, 3],
|
8
|
-
[5, 8, 13],
|
9
|
-
[0, 0, 0]
|
10
|
-
]
|
11
|
-
end
|
12
|
-
|
13
|
-
test_condition do
|
14
|
-
it 'will perform additions' do
|
15
|
-
expect(a + b).to eq answer
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'lambda parameter' do
|
21
|
-
data_condition(:a, :b, :answer) do
|
22
|
-
[
|
23
|
-
[1 , 2 , -> {should == 3}],
|
24
|
-
[5 , 8 , -> {should == 13}],
|
25
|
-
[0 , 0 , -> {should == 0}]
|
26
|
-
]
|
27
|
-
end
|
28
|
-
|
29
|
-
test_condition do
|
30
|
-
subject {a + b}
|
31
|
-
it 'will perform additions' do
|
32
|
-
self.instance_exec(&answer)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'table separated with pipe' do
|
38
|
-
data_table(:a, :b, :answer) do
|
39
|
-
1 | 2 | 3
|
40
|
-
'hello ' | 'world' | 'hello world'
|
41
|
-
[1, 2, 3] | [4, 5, 6] | [1, 2, 3, 4, 5, 6]
|
42
|
-
end
|
43
|
-
|
44
|
-
test_condition do
|
45
|
-
it 'will calculate that a plus b is answer' do
|
46
|
-
expect(a + b).to eq answer
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'table separated with pipe (using Tabular syntax)' do
|
52
|
-
using RSpec::Specify::Parameterized::Tabular
|
53
|
-
|
54
|
-
data_condition(:a, :b, :answer) do
|
55
|
-
1 | 2 | 3
|
56
|
-
'hello ' | 'world' | 'hello world'
|
57
|
-
[1, 2, 3] | [4, 5, 6] | [1, 2, 3, 4, 5, 6]
|
58
|
-
end
|
59
|
-
|
60
|
-
test_condition do
|
61
|
-
it 'will calculate that a plus b is answer' do
|
62
|
-
expect(a + b).to eq answer
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'table separated with pipe and lambda parameter (using Tabular syntax)' do
|
68
|
-
using RSpec::Specify::Parameterized::Tabular
|
69
|
-
|
70
|
-
data_condition(:a, :b, :matcher) do
|
71
|
-
1 | 2 | -> { eq(3) }
|
72
|
-
'hello ' | 'world' | -> { eq('hello world') }
|
73
|
-
[1, 2, 3] | [4, 5, 6] | -> { be_a(Array) }
|
74
|
-
end
|
75
|
-
|
76
|
-
test_condition do
|
77
|
-
it 'will calculate that a plus b is answer' do
|
78
|
-
expect(a + b).to instance_exec(&matcher)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when the data_condition block is after test_condition' do
|
84
|
-
test_condition do
|
85
|
-
it 'will perform additions' do
|
86
|
-
expect(a + b).to eq answer
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
test_condition do
|
91
|
-
subject { a }
|
92
|
-
it { should be_a Numeric }
|
93
|
-
end
|
94
|
-
|
95
|
-
data_condition(:a, :b, :answer) do
|
96
|
-
[
|
97
|
-
[1 , 2 , 3],
|
98
|
-
[5 , 8 , 13],
|
99
|
-
[0 , 0 , 0]
|
100
|
-
]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'when the data_condition block is between test_condition blocks' do
|
105
|
-
test_condition do
|
106
|
-
it 'should perform additions' do
|
107
|
-
expect(a + b).to eq answer
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
data_condition(:a, :b, :answer) do
|
112
|
-
[
|
113
|
-
[1 , 2 , 3],
|
114
|
-
[5 , 8 , 13],
|
115
|
-
[0 , 0 , 0]
|
116
|
-
]
|
117
|
-
end
|
118
|
-
|
119
|
-
test_condition do
|
120
|
-
subject { a }
|
121
|
-
it { should be_a Numeric }
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'when the data_condition has only one parameter to be set' do
|
126
|
-
data_condition(:x) do
|
127
|
-
[1, 2, 3]
|
128
|
-
end
|
129
|
-
|
130
|
-
test_condition do
|
131
|
-
it 'can take an array of elements' do
|
132
|
-
expect(x).to eq x
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'when the table has only a row' do
|
138
|
-
data_table(:a, :b, :answer) do
|
139
|
-
1 | 2 | 3
|
140
|
-
end
|
141
|
-
|
142
|
-
test_condition do
|
143
|
-
it 'will calculate that a plus b is answer' do
|
144
|
-
expect(a + b).to eq answer
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'when the table has only a row (using Tabular format)' do
|
150
|
-
using RSpec::Specify::Parameterized::Tabular
|
151
|
-
|
152
|
-
data_condition(:a, :b, :answer) do
|
153
|
-
1 | 2 | 3
|
154
|
-
end
|
155
|
-
|
156
|
-
test_condition do
|
157
|
-
it 'will calculate that a plus b is answer' do
|
158
|
-
expect(a + b).to eq answer
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when the data_condition has let variables, defined by parent example group' do
|
164
|
-
describe 'parent (define let)' do
|
165
|
-
let(:five) { 5 }
|
166
|
-
let(:eight) { 8 }
|
167
|
-
|
168
|
-
describe 'child 1' do
|
169
|
-
data_condition(:a, :b, :answer) do
|
170
|
-
[
|
171
|
-
[1 , 2 , 3],
|
172
|
-
[five , eight , 13],
|
173
|
-
]
|
174
|
-
end
|
175
|
-
|
176
|
-
test_condition do
|
177
|
-
it 'will calculate that a plus b is answer' do
|
178
|
-
expect(a + b).to eq answer
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
describe 'child 2 (data_table)' do
|
184
|
-
data_table(:a, :b, :answer) do
|
185
|
-
1 | 2 | 3
|
186
|
-
five | eight | 13
|
187
|
-
end
|
188
|
-
|
189
|
-
test_condition do
|
190
|
-
it 'will calculate that a plus b is answer' do
|
191
|
-
expect(a + b).to eq answer
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe 'child 3 (Using Tabular)' do
|
197
|
-
using RSpec::Specify::Parameterized::Tabular
|
198
|
-
|
199
|
-
data_condition(:a, :b, :answer) do
|
200
|
-
1 | 2 | 3
|
201
|
-
five | eight | 13
|
202
|
-
end
|
203
|
-
|
204
|
-
test_condition do
|
205
|
-
it 'will calculate that a plus b is answer' do
|
206
|
-
expect(a + b).to eq answer
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
let(:eq_matcher) { eq(13) }
|
212
|
-
describe 'child 3 (use matcher)' do
|
213
|
-
data_condition(:a, :b, :matcher) do
|
214
|
-
[
|
215
|
-
[1 , 2 , eq(3) ],
|
216
|
-
[five , eight , eq_matcher],
|
217
|
-
]
|
218
|
-
end
|
219
|
-
|
220
|
-
test_condition do
|
221
|
-
it 'will calculate that a plus b is answer' do
|
222
|
-
expect(a + b).to matcher
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|