r_spec-clone 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/r_spec.rb +70 -19
- data/lib/r_spec/clone/console.rb +0 -2
- data/lib/r_spec/clone/dsl.rb +159 -17
- data/lib/r_spec/clone/error.rb +0 -2
- data/lib/r_spec/clone/error/pending_expectation.rb +0 -2
- data/lib/r_spec/clone/error/reserved_method.rb +0 -2
- data/lib/r_spec/clone/error/undefined_described_class.rb +0 -2
- data/lib/r_spec/clone/error/undefined_subject.rb +0 -2
- data/lib/r_spec/clone/expectation_target.rb +0 -2
- data/lib/r_spec/clone/expectation_target/base.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90252cd64a48b7b40aa2424c1c09c69227e45e414ac5fd8d14a53697c0b1c180
|
4
|
+
data.tar.gz: 7eb7211ac34e5dfc2f1f74ae17d354f2704feb41e400d5fada1ccaa764912413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7fc657a588d0efd081ead62736ddd0f2595e09f0e4db6df235550503325d46cb4814110e16a4fb55244c07de645878d1e08eab40e5ddcc0226b3a64e318091d
|
7
|
+
data.tar.gz: ff205ff80822fea221bbcd27bf8a43925617146be2bf48d0c24d525bbe530921ce6f835530bce0cad53ef6f3e694278b6bd9655dbd4506f3691365cb15ce800a
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ A basic spec looks something like this:
|
|
67
67
|
|
68
68
|
### Anatomy of a spec file
|
69
69
|
|
70
|
-
To use the `RSpec` module and its DSL, you need to add `require "r_spec
|
70
|
+
To use the `RSpec` module and its DSL, you need to add `require "r_spec"` to your spec files.
|
71
71
|
Many projects use a custom spec helper which organizes these includes.
|
72
72
|
|
73
73
|
Concrete test cases are defined in `it` blocks.
|
data/lib/r_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative File.join("r_spec", "clone", "dsl")
|
|
5
5
|
# Top level namespace for the RSpec clone.
|
6
6
|
#
|
7
7
|
# @example The true from the false
|
8
|
-
# require "r_spec
|
8
|
+
# require "r_spec"
|
9
9
|
#
|
10
10
|
# RSpec.describe "The true from the false" do
|
11
11
|
# it { expect(false).not_to be true }
|
@@ -15,7 +15,7 @@ require_relative File.join("r_spec", "clone", "dsl")
|
|
15
15
|
# # Success: expected false not to be true.
|
16
16
|
#
|
17
17
|
# @example The basic behavior of arrays
|
18
|
-
# require "r_spec
|
18
|
+
# require "r_spec"
|
19
19
|
#
|
20
20
|
# RSpec.describe Array do
|
21
21
|
# describe "#size" do
|
@@ -41,7 +41,7 @@ require_relative File.join("r_spec", "clone", "dsl")
|
|
41
41
|
# # Success: expected false to be false.
|
42
42
|
#
|
43
43
|
# @example An inherited definition of let
|
44
|
-
# require "r_spec
|
44
|
+
# require "r_spec"
|
45
45
|
#
|
46
46
|
# RSpec.describe Integer do
|
47
47
|
# let(:answer) { 42 }
|
@@ -69,7 +69,7 @@ module RSpec
|
|
69
69
|
# array_ versus _array with elements_.
|
70
70
|
#
|
71
71
|
# @example
|
72
|
-
# require "r_spec
|
72
|
+
# require "r_spec"
|
73
73
|
#
|
74
74
|
# RSpec.context "when divided by zero" do
|
75
75
|
# subject { 42 / 0 }
|
@@ -83,30 +83,62 @@ module RSpec
|
|
83
83
|
# @param description [String] A description that usually begins with "when",
|
84
84
|
# "with" or "without".
|
85
85
|
# @param block [Proc] The block to define the specs.
|
86
|
-
#
|
87
|
-
# @api public
|
88
86
|
def self.context(description, &block)
|
89
87
|
Clone::Dsl.context(description, &block)
|
90
88
|
end
|
91
89
|
|
92
90
|
# :nocov:
|
93
|
-
|
91
|
+
|
94
92
|
# Runs a context example group in a subprocess to isolate side effects.
|
95
93
|
#
|
94
|
+
# @example
|
95
|
+
# str = "Hello, world!"
|
96
|
+
#
|
97
|
+
# require "r_spec"
|
98
|
+
#
|
99
|
+
# RSpec.context! "when a string becomes uppercase" do
|
100
|
+
# before do
|
101
|
+
# str.upcase!
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# it { expect(str).to eq "HELLO, WORLD!" }
|
105
|
+
# end
|
106
|
+
#
|
107
|
+
# # Output to the console
|
108
|
+
# # Success: expected to eq "HELLO, WORLD!".
|
109
|
+
#
|
110
|
+
# RSpec.it { expect(str).to eq "Hello, world!" }
|
111
|
+
#
|
112
|
+
# # Output to the console
|
113
|
+
# # Success: expected to eq "Hello, world!".
|
114
|
+
#
|
96
115
|
# @param (see #context)
|
97
116
|
def self.context!(description, &block)
|
98
117
|
Clone::Dsl.context!(description, &block)
|
99
118
|
end
|
119
|
+
|
100
120
|
# :nocov:
|
101
121
|
|
102
122
|
# Defines an example group that describes a unit to be tested.
|
103
123
|
#
|
104
124
|
# @example
|
105
|
-
# require "r_spec
|
125
|
+
# require "r_spec"
|
126
|
+
#
|
127
|
+
# RSpec.describe String do
|
128
|
+
# it { expect(described_class).to be String }
|
129
|
+
# end
|
130
|
+
#
|
131
|
+
# # Output to the console
|
132
|
+
# # Success: expected to be String.
|
133
|
+
#
|
134
|
+
# @example
|
135
|
+
# require "r_spec"
|
106
136
|
#
|
107
137
|
# RSpec.describe String do
|
138
|
+
# let(:foo) { "foo" }
|
139
|
+
#
|
108
140
|
# describe "+" do
|
109
|
-
# it("concats") { expect(
|
141
|
+
# it("concats") { expect(foo + "bar").to eq "foobar" }
|
110
142
|
# end
|
111
143
|
# end
|
112
144
|
#
|
@@ -115,20 +147,40 @@ module RSpec
|
|
115
147
|
#
|
116
148
|
# @param const [Module, String] A module to include in block context.
|
117
149
|
# @param block [Proc] The block to define the specs.
|
118
|
-
#
|
119
|
-
# @api public
|
120
150
|
def self.describe(const, &block)
|
121
151
|
Clone::Dsl.describe(const, &block)
|
122
152
|
end
|
123
153
|
|
124
154
|
# :nocov:
|
125
|
-
|
155
|
+
|
126
156
|
# Runs a describe example group in a subprocess to isolate side effects.
|
127
157
|
#
|
158
|
+
# @example
|
159
|
+
# $app = "foo"
|
160
|
+
#
|
161
|
+
# require "r_spec"
|
162
|
+
#
|
163
|
+
# RSpec.describe! "#gsub!" do
|
164
|
+
# before do
|
165
|
+
# $app.gsub!("o", "0")
|
166
|
+
# end
|
167
|
+
#
|
168
|
+
# it { expect($app).to eq "f00" }
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# # Output to the console
|
172
|
+
# # Success: expected to eq "f00".
|
173
|
+
#
|
174
|
+
# RSpec.it { expect($app).to eq "foo" }
|
175
|
+
#
|
176
|
+
# # Output to the console
|
177
|
+
# # Success: expected to eq "foo".
|
178
|
+
#
|
128
179
|
# @param (see #describe)
|
129
180
|
def self.describe!(const, &block)
|
130
181
|
Clone::Dsl.describe!(const, &block)
|
131
182
|
end
|
183
|
+
|
132
184
|
# :nocov:
|
133
185
|
|
134
186
|
# Defines a concrete test case.
|
@@ -136,7 +188,7 @@ module RSpec
|
|
136
188
|
# The test is performed by the block supplied to &block.
|
137
189
|
#
|
138
190
|
# @example The integer after 41
|
139
|
-
# require "r_spec
|
191
|
+
# require "r_spec"
|
140
192
|
#
|
141
193
|
# RSpec.it { expect(41.next).to be 42 }
|
142
194
|
#
|
@@ -151,19 +203,19 @@ module RSpec
|
|
151
203
|
#
|
152
204
|
# @raise (see RSpec::ExpectationTarget::Base#result)
|
153
205
|
# @return (see RSpec::ExpectationTarget::Base#result)
|
154
|
-
#
|
155
|
-
# @api public
|
156
206
|
def self.it(name = nil, &block)
|
157
207
|
Clone::Dsl.it(name, &block)
|
158
208
|
end
|
159
209
|
|
160
210
|
# :nocov:
|
161
|
-
|
211
|
+
|
162
212
|
# Runs a concrete test case in a subprocess to isolate side effects.
|
163
213
|
#
|
164
214
|
# @example
|
165
215
|
# app = "Hello, world!"
|
166
216
|
#
|
217
|
+
# require "r_spec"
|
218
|
+
#
|
167
219
|
# RSpec.it! { expect(app.gsub!("world", "Alice")).to eq "Hello, Alice!" }
|
168
220
|
#
|
169
221
|
# # Output to the console
|
@@ -181,6 +233,7 @@ module RSpec
|
|
181
233
|
def self.it!(name = nil, &block)
|
182
234
|
Clone::Dsl.it!(name, &block)
|
183
235
|
end
|
236
|
+
|
184
237
|
# :nocov:
|
185
238
|
|
186
239
|
# Defines a pending test case.
|
@@ -189,7 +242,7 @@ module RSpec
|
|
189
242
|
# not yet implemented.
|
190
243
|
#
|
191
244
|
# @example
|
192
|
-
# require "r_spec
|
245
|
+
# require "r_spec"
|
193
246
|
#
|
194
247
|
# RSpec.pending "is implemented but waiting" do
|
195
248
|
# expect something to be finished
|
@@ -207,8 +260,6 @@ module RSpec
|
|
207
260
|
# @param message [String] The reason why the example is pending.
|
208
261
|
#
|
209
262
|
# @return [nil] Write a message to STDOUT.
|
210
|
-
#
|
211
|
-
# @api public
|
212
263
|
def self.pending(message)
|
213
264
|
Clone::Dsl.pending(message)
|
214
265
|
end
|
data/lib/r_spec/clone/console.rb
CHANGED
data/lib/r_spec/clone/dsl.rb
CHANGED
@@ -16,7 +16,7 @@ module RSpec
|
|
16
16
|
# Executes the given block before each spec in the current context runs.
|
17
17
|
#
|
18
18
|
# @example
|
19
|
-
# require "r_spec
|
19
|
+
# require "r_spec"
|
20
20
|
#
|
21
21
|
# RSpec.describe Integer do
|
22
22
|
# before do
|
@@ -42,6 +42,8 @@ module RSpec
|
|
42
42
|
# # Success: expected to be 123.
|
43
43
|
#
|
44
44
|
# @param block [Proc] The content to execute at the class initialization.
|
45
|
+
#
|
46
|
+
# @api public
|
45
47
|
def self.before(&block)
|
46
48
|
define_method(BEFORE_METHOD) do
|
47
49
|
super()
|
@@ -54,7 +56,7 @@ module RSpec
|
|
54
56
|
# Executes the given block after each spec in the current context runs.
|
55
57
|
#
|
56
58
|
# @example
|
57
|
-
# require "r_spec
|
59
|
+
# require "r_spec"
|
58
60
|
#
|
59
61
|
# RSpec.describe Integer do
|
60
62
|
# after do
|
@@ -69,6 +71,8 @@ module RSpec
|
|
69
71
|
# # That is the answer to everything.
|
70
72
|
#
|
71
73
|
# @param block [Proc] The content to execute at the class initialization.
|
74
|
+
#
|
75
|
+
# @api public
|
72
76
|
def self.after(&block)
|
73
77
|
define_method(AFTER_METHOD) do
|
74
78
|
instance_exec(&block)
|
@@ -81,7 +85,7 @@ module RSpec
|
|
81
85
|
# Sets a user-defined property.
|
82
86
|
#
|
83
87
|
# @example
|
84
|
-
# require "r_spec
|
88
|
+
# require "r_spec"
|
85
89
|
#
|
86
90
|
# RSpec.describe "Name stories" do
|
87
91
|
# let(:name) { "Bob" }
|
@@ -103,6 +107,8 @@ module RSpec
|
|
103
107
|
# @param block [Proc] The content of the method to define.
|
104
108
|
#
|
105
109
|
# @return [Symbol] A private method that define the block content.
|
110
|
+
#
|
111
|
+
# @api public
|
106
112
|
def self.let(name, *args, **kwargs, &block)
|
107
113
|
raise Error::ReservedMethod if [BEFORE_METHOD, AFTER_METHOD].include?(name.to_sym)
|
108
114
|
|
@@ -112,7 +118,7 @@ module RSpec
|
|
112
118
|
# Sets a user-defined property named {#subject}.
|
113
119
|
#
|
114
120
|
# @example
|
115
|
-
# require "r_spec
|
121
|
+
# require "r_spec"
|
116
122
|
#
|
117
123
|
# RSpec.describe Array do
|
118
124
|
# subject { [1, 2, 3] }
|
@@ -120,13 +126,23 @@ module RSpec
|
|
120
126
|
# it "has the prescribed elements" do
|
121
127
|
# expect(subject).to eq([1, 2, 3])
|
122
128
|
# end
|
129
|
+
#
|
130
|
+
# it { is_expected.to be_an_instance_of described_class }
|
131
|
+
#
|
132
|
+
# its(:size) { is_expected.to be 3 }
|
133
|
+
# its(:downcase) { is_expected.to raise_exception NoMethodError }
|
123
134
|
# end
|
124
135
|
#
|
125
136
|
# # Output to the console
|
126
137
|
# # Success: expected to eq [1, 2, 3].
|
138
|
+
# # Success: expected [1, 2, 3] to be an instance of Array.
|
139
|
+
# # Success: expected to be 3.
|
140
|
+
# # Success: undefined method `downcase' for [1, 2, 3]:Array.
|
127
141
|
#
|
128
142
|
# @param block [Proc] The subject to set.
|
129
143
|
# @return [Symbol] A {#subject} method that define the block content.
|
144
|
+
#
|
145
|
+
# @api public
|
130
146
|
def self.subject(&block)
|
131
147
|
let(__method__, &block)
|
132
148
|
end
|
@@ -134,7 +150,7 @@ module RSpec
|
|
134
150
|
# Defines an example group that describes a unit to be tested.
|
135
151
|
#
|
136
152
|
# @example
|
137
|
-
# require "r_spec
|
153
|
+
# require "r_spec"
|
138
154
|
#
|
139
155
|
# RSpec.describe String do
|
140
156
|
# describe "+" do
|
@@ -147,6 +163,8 @@ module RSpec
|
|
147
163
|
#
|
148
164
|
# @param const [Module, String] A module to include in block context.
|
149
165
|
# @param block [Proc] The block to define the specs.
|
166
|
+
#
|
167
|
+
# @api public
|
150
168
|
def self.describe(const, &block)
|
151
169
|
desc = ::Class.new(self)
|
152
170
|
desc.let(:described_class) { const } if const.is_a?(::Module)
|
@@ -154,20 +172,53 @@ module RSpec
|
|
154
172
|
end
|
155
173
|
|
156
174
|
# :nocov:
|
157
|
-
|
175
|
+
|
158
176
|
# Runs a describe example group in a subprocess to isolate side effects.
|
159
177
|
#
|
178
|
+
# @example
|
179
|
+
# $app = "foo"
|
180
|
+
#
|
181
|
+
# require "r_spec"
|
182
|
+
#
|
183
|
+
# RSpec.describe "Scoped side effects" do
|
184
|
+
# describe! "#gsub!" do
|
185
|
+
# before do
|
186
|
+
# $app.gsub!("o", "0")
|
187
|
+
# end
|
188
|
+
#
|
189
|
+
# context! "when isolated in the context" do
|
190
|
+
# before do
|
191
|
+
# $app.gsub!("f", "F")
|
192
|
+
# end
|
193
|
+
#
|
194
|
+
# it { expect($app).to eq "F00" }
|
195
|
+
# end
|
196
|
+
#
|
197
|
+
# it { expect($app).to eq "f00" }
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# it { expect($app).to eq "foo" }
|
201
|
+
# end
|
202
|
+
#
|
203
|
+
# # Output to the console
|
204
|
+
# # Success: expected to eq "F00".
|
205
|
+
# # Success: expected to eq "f00".
|
206
|
+
# # Success: expected to eq "foo".
|
207
|
+
#
|
160
208
|
# @param (see #describe)
|
209
|
+
#
|
210
|
+
# @api public
|
161
211
|
def self.describe!(const, &block)
|
162
212
|
fork! { describe(const, &block) }
|
163
213
|
end
|
214
|
+
|
164
215
|
# :nocov:
|
165
216
|
|
166
217
|
# Defines an example group that establishes a specific context, like
|
167
218
|
# _empty array_ versus _array with elements_.
|
168
219
|
#
|
169
220
|
# @example
|
170
|
-
# require "r_spec
|
221
|
+
# require "r_spec"
|
171
222
|
#
|
172
223
|
# RSpec.describe "web resource" do
|
173
224
|
# context "when resource is not found" do
|
@@ -186,19 +237,55 @@ module RSpec
|
|
186
237
|
# @param _description [String] A description that usually begins with
|
187
238
|
# "when", "with" or "without".
|
188
239
|
# @param block [Proc] The block to define the specs.
|
240
|
+
#
|
241
|
+
# @api public
|
189
242
|
def self.context(_description, &block)
|
190
243
|
desc = ::Class.new(self)
|
191
244
|
desc.instance_eval(&block)
|
192
245
|
end
|
193
246
|
|
194
247
|
# :nocov:
|
195
|
-
|
248
|
+
|
196
249
|
# Runs a context example group in a subprocess to isolate side effects.
|
197
250
|
#
|
251
|
+
# @example
|
252
|
+
# app = "Hello, world!"
|
253
|
+
#
|
254
|
+
# require "r_spec"
|
255
|
+
#
|
256
|
+
# RSpec.describe String do
|
257
|
+
# subject do
|
258
|
+
# app
|
259
|
+
# end
|
260
|
+
#
|
261
|
+
# before do
|
262
|
+
# subject.gsub!("world", person)
|
263
|
+
# end
|
264
|
+
#
|
265
|
+
# context! "when Alice is greeted" do
|
266
|
+
# let(:person) { "Alice" }
|
267
|
+
#
|
268
|
+
# it { is_expected.to eq "Hello, Alice!" }
|
269
|
+
# end
|
270
|
+
#
|
271
|
+
# context! "when Bob is greeted" do
|
272
|
+
# let(:person) { "Bob" }
|
273
|
+
#
|
274
|
+
# it { is_expected.to eq "Hello, Bob!" }
|
275
|
+
# end
|
276
|
+
# end
|
277
|
+
#
|
278
|
+
# # Output to the console
|
279
|
+
# # Success: expected to eq "Hello, Alice!".
|
280
|
+
# # Success: expected to eq "Hello, Bob!".
|
281
|
+
#
|
198
282
|
# @param (see #context)
|
283
|
+
#
|
284
|
+
# @api public
|
199
285
|
def self.context!(description, &block)
|
200
286
|
fork! { context(description, &block) }
|
201
287
|
end
|
288
|
+
|
202
289
|
# :nocov:
|
203
290
|
|
204
291
|
# Defines a concrete test case.
|
@@ -206,7 +293,7 @@ module RSpec
|
|
206
293
|
# The test is performed by the block supplied to `&block`.
|
207
294
|
#
|
208
295
|
# @example The integer after 41
|
209
|
-
# require "r_spec
|
296
|
+
# require "r_spec"
|
210
297
|
#
|
211
298
|
# RSpec.describe Integer do
|
212
299
|
# it { expect(41.next).to be 42 }
|
@@ -216,7 +303,7 @@ module RSpec
|
|
216
303
|
# # Success: expected to be 42.
|
217
304
|
#
|
218
305
|
# @example A division by zero
|
219
|
-
# require "r_spec
|
306
|
+
# require "r_spec"
|
220
307
|
#
|
221
308
|
# RSpec.describe Integer do
|
222
309
|
# subject { 41 }
|
@@ -239,29 +326,55 @@ module RSpec
|
|
239
326
|
#
|
240
327
|
# @raise (see ExpectationTarget::Base#result)
|
241
328
|
# @return (see ExpectationTarget::Base#result)
|
329
|
+
#
|
330
|
+
# @api public
|
242
331
|
def self.it(_name = nil, &block)
|
243
332
|
example = ::Class.new(self) { include ExpectationHelper::It }.new
|
244
333
|
run(example, &block)
|
245
334
|
end
|
246
335
|
|
247
336
|
# :nocov:
|
248
|
-
|
337
|
+
|
249
338
|
# Runs a concrete test case in a subprocess to isolate side effects.
|
250
339
|
#
|
340
|
+
# @example
|
341
|
+
# app = "foo"
|
342
|
+
#
|
343
|
+
# require "r_spec"
|
344
|
+
#
|
345
|
+
# RSpec.describe "Side effects per example" do
|
346
|
+
# it! "runs the example in isolation" do
|
347
|
+
# expect { app.gsub!("foo", "bar") }.to eq "bar"
|
348
|
+
# expect(app).to eq "bar"
|
349
|
+
# end
|
350
|
+
#
|
351
|
+
# it "runs the example" do
|
352
|
+
# expect(app).to eq "foo"
|
353
|
+
# end
|
354
|
+
# end
|
355
|
+
#
|
356
|
+
# # Output to the console
|
357
|
+
# # Success: expected to eq "bar".
|
358
|
+
# # Success: expected to eq "bar".
|
359
|
+
# # Success: expected to eq "foo".
|
360
|
+
#
|
251
361
|
# @param (see #it)
|
252
362
|
#
|
253
363
|
# @raise (see ExpectationTarget::Base#result)
|
254
364
|
# @return (see ExpectationTarget::Base#result)
|
365
|
+
#
|
366
|
+
# @api public
|
255
367
|
def self.it!(name = nil, &block)
|
256
368
|
fork! { it(name, &block) }
|
257
369
|
end
|
370
|
+
|
258
371
|
# :nocov:
|
259
372
|
|
260
373
|
# Defines a single concrete test case that specifies the actual value of
|
261
374
|
# an attribute of the subject using {ExpectationHelper::Its#is_expected}.
|
262
375
|
#
|
263
376
|
# @example The integer after 41
|
264
|
-
# require "r_spec
|
377
|
+
# require "r_spec"
|
265
378
|
#
|
266
379
|
# RSpec.describe Integer do
|
267
380
|
# subject { 41 }
|
@@ -273,7 +386,7 @@ module RSpec
|
|
273
386
|
# # Success: expected to be 42.
|
274
387
|
#
|
275
388
|
# @example A division by zero
|
276
|
-
# require "r_spec
|
389
|
+
# require "r_spec"
|
277
390
|
#
|
278
391
|
# RSpec.describe Integer do
|
279
392
|
# subject { 41 }
|
@@ -285,10 +398,10 @@ module RSpec
|
|
285
398
|
# # Success: divided by 0.
|
286
399
|
#
|
287
400
|
# @example A spec without subject
|
288
|
-
# require "r_spec
|
401
|
+
# require "r_spec"
|
289
402
|
#
|
290
403
|
# RSpec.describe Integer do
|
291
|
-
# its(:
|
404
|
+
# its(:abs) { is_expected.to raise_exception RSpec::Clone::Error::UndefinedSubject }
|
292
405
|
# end
|
293
406
|
#
|
294
407
|
# # Output to the console
|
@@ -301,6 +414,8 @@ module RSpec
|
|
301
414
|
#
|
302
415
|
# @raise (see ExpectationTarget::Base#result)
|
303
416
|
# @return (see ExpectationTarget::Base#result)
|
417
|
+
#
|
418
|
+
# @api public
|
304
419
|
def self.its(attribute, *args, **kwargs, &block)
|
305
420
|
example = ::Class.new(self) do
|
306
421
|
include ExpectationHelper::Its
|
@@ -314,17 +429,41 @@ module RSpec
|
|
314
429
|
end
|
315
430
|
|
316
431
|
# :nocov:
|
317
|
-
|
432
|
+
|
318
433
|
# Runs a single concrete test case in a subprocess to isolate side
|
319
434
|
# effects.
|
320
435
|
#
|
436
|
+
# @example
|
437
|
+
# app = "foo"
|
438
|
+
#
|
439
|
+
# require "r_spec"
|
440
|
+
#
|
441
|
+
# RSpec.describe "Isolated side effect" do
|
442
|
+
# subject do
|
443
|
+
# app
|
444
|
+
# end
|
445
|
+
#
|
446
|
+
# its!(:upcase) { is_expected.to eq "FOO" }
|
447
|
+
#
|
448
|
+
# it "tests the original value" do
|
449
|
+
# expect(app).to eq "foo"
|
450
|
+
# end
|
451
|
+
# end
|
452
|
+
#
|
453
|
+
# # Output to the console
|
454
|
+
# # Success: expected to eq "FOO".
|
455
|
+
# # Success: expected to eq "foo".
|
456
|
+
#
|
321
457
|
# @param (see #it)
|
322
458
|
#
|
323
459
|
# @raise (see ExpectationTarget::Base#result)
|
324
460
|
# @return (see ExpectationTarget::Base#result)
|
461
|
+
#
|
462
|
+
# @api public
|
325
463
|
def self.its!(attribute, *args, **kwargs, &block)
|
326
464
|
fork! { its(attribute, *args, **kwargs, &block) }
|
327
465
|
end
|
466
|
+
|
328
467
|
# :nocov:
|
329
468
|
|
330
469
|
# Defines a pending test case.
|
@@ -333,7 +472,7 @@ module RSpec
|
|
333
472
|
# is not yet implemented.
|
334
473
|
#
|
335
474
|
# @example
|
336
|
-
# require "r_spec
|
475
|
+
# require "r_spec"
|
337
476
|
#
|
338
477
|
# RSpec.describe "an example" do
|
339
478
|
# pending "is implemented but waiting" do
|
@@ -379,11 +518,14 @@ module RSpec
|
|
379
518
|
|
380
519
|
private
|
381
520
|
|
521
|
+
# If the first argument to a {.describe} definition is a class (or a
|
522
|
+
# module), this method will be overridden to return it.
|
382
523
|
def described_class
|
383
524
|
raise Error::UndefinedDescribedClass,
|
384
525
|
"the first argument to at least one example group must be a module"
|
385
526
|
end
|
386
527
|
|
528
|
+
# If a subject is defined, this method will be overridden to return it.
|
387
529
|
def subject
|
388
530
|
raise Error::UndefinedSubject, "subject not explicitly defined"
|
389
531
|
end
|
data/lib/r_spec/clone/error.rb
CHANGED
@@ -6,8 +6,6 @@ require_relative File.join("expectation_target", "value")
|
|
6
6
|
module RSpec
|
7
7
|
module Clone
|
8
8
|
# Wraps the target of an expectation.
|
9
|
-
#
|
10
|
-
# @api private
|
11
9
|
module ExpectationTarget
|
12
10
|
# @param undefined_value A sentinel value to be able to tell when the user
|
13
11
|
# did not pass an argument. We can't use `nil` for that because `nil` is a
|
@@ -63,8 +63,6 @@ module RSpec
|
|
63
63
|
#
|
64
64
|
# @raise [SystemExit] Terminate execution immediately by calling
|
65
65
|
# `Kernel.exit(false)` with a failure message written to STDERR.
|
66
|
-
#
|
67
|
-
# @api private
|
68
66
|
def result(passed, actual:, error:, got:, matcher:, negate:)
|
69
67
|
Console.passed_spec ::Expresenter.call(passed).with(
|
70
68
|
actual: actual,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_spec-clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expresenter
|