r_spec 1.0.0.beta6 → 1.0.0.beta11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6facf7764beddac81425ab44d80ed3b306f6c63c3532401bb658240654b06845
4
- data.tar.gz: 944d53b22a1ffeeca3afe990aa99a613493f9ff1b3aad3ceaa43ae0b9a8ec019
3
+ metadata.gz: 8c7957c4316cd89f58118ce544d50f3b5f401962648415b535c97da57ae4b7db
4
+ data.tar.gz: a1e8ec62ac5d695203917c85674a1d9b5dccbf1993c4fb55569fdd9d9401220b
5
5
  SHA512:
6
- metadata.gz: c28b4fbd53cf2a368022418c2ccbbf31cf4a35abce141f0999285bff90b4c84d7f36209894dafcf5362464d01fad3dcb724d942ae5db5c1095387997b087964f
7
- data.tar.gz: 4c7a23212c2ce90a67b04e9fe25dda7812c37902eba8f6febdb9e4e2dcd33633fa43642d6905f9bfffa6215b467eb88cbb921d596f0276fb788cc876bc63e291
6
+ metadata.gz: 51375c2f10d7cc11e71041c538940956e94721ae8f6e72af2bbb770d0b73041f6845b0100e9ebec2f7ec5d178fef388d5a5ece60e41076d7ff659d1d035afabd
7
+ data.tar.gz: 512ec78cc25d9ec8e0b5661c9a14b1fae3ae73714d8dc21e291721277ee6741035f5ccf130e190d661e8b19caf5d356d603a9951b40ad74b7fbdd20f7f9e6fec
data/README.md CHANGED
@@ -7,13 +7,14 @@ A minimalist __[RSpec](https://github.com/rspec/rspec) clone__ with all the esse
7
7
  ## Status
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/r_spec.svg)](https://badge.fury.io/rb/r_spec)
10
- [![Build Status](https://travis-ci.org/cyril/r_spec.rb.svg?branch=main)](https://travis-ci.org/cyril/r_spec.rb)
11
- [![Inline Docs](https://inch-ci.org/github/cyril/r_spec.rb.svg)](https://inch-ci.org/github/cyril/r_spec.rb)
12
10
  [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)](https://rubydoc.info/gems/r_spec/frames)
11
+ [![CI](https://github.com/cyril/r_spec.rb/workflows/CI/badge.svg?branch=main)](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Aci+branch%3Amain)
12
+ [![RuboCop](https://github.com/cyril/r_spec.rb/workflows/RuboCop/badge.svg?branch=main)](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Arubocop+branch%3Amain)
13
13
 
14
- ## Goal
14
+ ## Project goals
15
15
 
16
- This clone attempts to provide most of RSpec's DSL to express expected outcomes of a code example without magic power.
16
+ * Enforce the guidelines and best practices outlined in the community [RSpec style guide](https://rspec.rubystyle.guide/).
17
+ * Provide most of RSpec's DSL to express expected outcomes of a code example without magic power.
17
18
 
18
19
  ## Some differences
19
20
 
@@ -28,6 +29,8 @@ This clone attempts to provide most of RSpec's DSL to express expected outcomes
28
29
  * [Arbitrary helper methods](https://relishapp.com/rspec/rspec-core/v/3-10/docs/helper-methods/arbitrary-helper-methods) are not exposed to examples.
29
30
  * The `let` method defines a helper method rather than a memoized helper method.
30
31
  * The one-liner `is_expected` syntax also works with block expectations.
32
+ * `subject`, `before`, `after` and `let` definitions must come before examples.
33
+ * Each `context` runs its tests in _isolation_ to prevent side effects.
31
34
 
32
35
  ## Important ⚠️
33
36
 
@@ -46,7 +49,7 @@ Following [RubyGems naming conventions](https://guides.rubygems.org/name-your-ge
46
49
  Add this line to your application's Gemfile:
47
50
 
48
51
  ```ruby
49
- gem "r_spec", ">= 1.0.0.beta6"
52
+ gem "r_spec", ">= 1.0.0.beta11"
50
53
  ```
51
54
 
52
55
  And then execute:
@@ -100,7 +103,8 @@ For unit tests, it is recommended to follow the conventions for method names:
100
103
  * instance methods are prefixed with `#`, class methods with `.`.
101
104
 
102
105
  To establish certain contexts — think _empty array_ versus _array with elements_ — the `context` method may be used to communicate this to the reader.
103
- It has a different name, but behaves exactly like `describe`.
106
+ Its behavior is slightly different from `describe` because each `context` runs its tests in isolation,
107
+ so side effects caused by testing do not propagate out of contexts.
104
108
 
105
109
  `describe` and `context` take an optional description as argument and a block containing the individual specs or nested groupings.
106
110
 
@@ -215,13 +219,11 @@ task default: :test
215
219
 
216
220
  ## Performance
217
221
 
218
- Benchmark against an single expectation executed 100 times from the console.
222
+ ### Runtime
219
223
 
220
- | Framework | Seconds to complete |
221
- |-------------|---------------------|
222
- | RSpec clone | [13.2](https://github.com/cyril/r_spec.rb/blob/main/benchmark/r_spec.rb) |
223
- | RSpec | [32.7](https://github.com/cyril/r_spec.rb/blob/main/benchmark/rspec.rb) |
224
- | minitest | [17.6](https://github.com/cyril/r_spec.rb/blob/main/benchmark/minitest.rb) |
224
+ Benchmark against [100 executions of a file containing one expectation](https://github.com/cyril/r_spec.rb/blob/main/benchmark/) (lower is better).
225
+
226
+ ![Runtime](https://r-spec.dev/benchmark-runtime.png)
225
227
 
226
228
  ## Test suite
227
229
 
@@ -229,8 +231,10 @@ __RSpec clone__'s specifications are self-described here: [spec/](https://github
229
231
 
230
232
  ## Contact
231
233
 
232
- * Home page: https://r-spec.dev
233
- * Source code: https://github.com/cyril/r_spec.rb
234
+ * Home page: [https://r-spec.dev/](https://r-spec.dev/)
235
+ * Cheatsheet: [https://r-spec.dev/cheatsheet.html](https://r-spec.dev/cheatsheet.html)
236
+ * Source code: [https://github.com/cyril/r_spec.rb](https://github.com/cyril/r_spec.rb)
237
+ * API Doc: [https://rubydoc.info/gems/r_spec](https://rubydoc.info/gems/r_spec)
234
238
  * Twitter: [https://twitter.com/cyri\_](https://twitter.com/cyri\_)
235
239
 
236
240
  ## Special thanks ❤️
@@ -253,3 +257,11 @@ __RSpec clone__ follows [Semantic Versioning 2.0](https://semver.org/).
253
257
  ## License
254
258
 
255
259
  The [gem](https://rubygems.org/gems/r_spec) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
260
+
261
+ ## One more thing
262
+
263
+ Under the hood, __RSpec clone__ is largely animated by [a collection of testing libraries designed to make programmers happy](https://github.com/fixrb/).
264
+
265
+ It's a living example of what we can do combining small libraries together that can boost the fun of programming.
266
+
267
+ ![Fix testing tools logo for Ruby](https://github.com/cyril/r_spec.rb/raw/main/img/fixrb.svg)
data/lib/r_spec.rb CHANGED
@@ -7,7 +7,7 @@ require_relative File.join("r_spec", "dsl")
7
7
  # @example The true from the false
8
8
  # require "r_spec"
9
9
  #
10
- # RSpec.describe do
10
+ # RSpec.describe "The true from the false" do
11
11
  # it { expect(false).not_to be true }
12
12
  # end
13
13
  #
@@ -65,13 +65,106 @@ require_relative File.join("r_spec", "dsl")
65
65
  #
66
66
  # @api public
67
67
  module RSpec
68
- # Specs are built with this method.
68
+ # Defines an example group that establishes a specific context, like _empty
69
+ # array_ versus _array with elements_.
70
+ #
71
+ # Unlike {.describe}, the block is evaluated in isolation in order to scope
72
+ # possible side effects inside its context.
73
+ #
74
+ # @example
75
+ # require "r_spec"
76
+ #
77
+ # RSpec.context "when divided by zero" do
78
+ # subject { 42 / 0 }
79
+ #
80
+ # it { is_expected.to raise_exception ZeroDivisionError }
81
+ # end
82
+ #
83
+ # # Output to the console
84
+ # # Success: divided by 0.
85
+ #
86
+ # @param description [String] A description that usually begins with "when",
87
+ # "with" or "without".
88
+ # @param block [Proc] The block to define the specs.
89
+ #
90
+ # @api public
91
+ def self.context(description, &block)
92
+ Dsl.context(description, &block)
93
+ end
94
+
95
+ # Defines an example group that describes a unit to be tested.
96
+ #
97
+ # @example
98
+ # require "r_spec"
99
+ #
100
+ # RSpec.describe String do
101
+ # describe "+" do
102
+ # it("concats") { expect("foo" + "bar").to eq "foobar" }
103
+ # end
104
+ # end
105
+ #
106
+ # # Output to the console
107
+ # # Success: expected to eq "foobar".
69
108
  #
70
109
  # @param const [Module, String] A module to include in block context.
71
110
  # @param block [Proc] The block to define the specs.
72
111
  #
73
112
  # @api public
74
- def self.describe(const = nil, &block)
113
+ def self.describe(const, &block)
75
114
  Dsl.describe(const, &block)
76
115
  end
116
+
117
+ # Defines a concrete test case.
118
+ #
119
+ # The test is performed by the block supplied to &block.
120
+ #
121
+ # @example The integer after 41
122
+ # require "r_spec"
123
+ #
124
+ # RSpec.it { expect(41.next).to be 42 }
125
+ #
126
+ # # Output to the console
127
+ # # Success: expected to be 42.
128
+ #
129
+ # It is usually used inside a {Dsl.describe} or {Dsl.context} section.
130
+ #
131
+ # @param name [String, nil] The name of the spec.
132
+ # @param block [Proc] An expectation to evaluate.
133
+ #
134
+ # @raise (see RSpec::ExpectationTarget::Base#result)
135
+ # @return (see RSpec::ExpectationTarget::Base#result)
136
+ #
137
+ # @api public
138
+ def self.it(name = nil, &block)
139
+ Dsl.it(name, &block)
140
+ end
141
+
142
+ # Defines a pending test case.
143
+ #
144
+ # `&block` is never evaluated. It can be used to describe behaviour that is
145
+ # not yet implemented.
146
+ #
147
+ # @example
148
+ # require "r_spec"
149
+ #
150
+ # RSpec.pending "is implemented but waiting" do
151
+ # expect something to be finished
152
+ # end
153
+ #
154
+ # RSpec.pending "is not yet implemented and waiting"
155
+ #
156
+ # # Output to the console
157
+ # # Warning: is implemented but waiting.
158
+ # # Warning: is not yet implemented and waiting.
159
+ #
160
+ # It is usually used inside a {Dsl.describe} or {Dsl.context} section.
161
+ #
162
+ # @param message [String] The reason why the example is pending.
163
+ #
164
+ # @return [nil] Write a message to STDOUT.
165
+ #
166
+ # @api public
167
+ def self.pending(message)
168
+ Dsl.pending(message)
169
+ end
77
170
  end
data/lib/r_spec/dsl.rb CHANGED
@@ -1,15 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "securerandom"
3
+ require "aw"
4
4
 
5
5
  require_relative "console"
6
6
  require_relative "error"
7
7
  require_relative "expectation_helper"
8
- require_relative "sandbox"
9
8
 
10
9
  module RSpec
11
10
  # Abstract class for handling the domain-specific language.
12
11
  class Dsl
12
+ BEFORE_METHOD = :initialize
13
+ AFTER_METHOD = :terminate
14
+
15
+ private_constant :BEFORE_METHOD, :AFTER_METHOD
16
+
13
17
  # Executes the given block before each spec in the current context runs.
14
18
  #
15
19
  # @example
@@ -40,12 +44,12 @@ module RSpec
40
44
  #
41
45
  # @param block [Proc] The content to execute at the class initialization.
42
46
  def self.before(&block)
43
- define_method(:initialize) do
47
+ define_method(BEFORE_METHOD) do
44
48
  super()
45
49
  instance_eval(&block)
46
50
  end
47
51
 
48
- private :initialize
52
+ private BEFORE_METHOD
49
53
  end
50
54
 
51
55
  # Executes the given block after each spec in the current context runs.
@@ -67,12 +71,12 @@ module RSpec
67
71
  #
68
72
  # @param block [Proc] The content to execute at the class initialization.
69
73
  def self.after(&block)
70
- define_method(:terminate) do
74
+ define_method(AFTER_METHOD) do
71
75
  instance_exec(&block)
72
76
  super()
73
77
  end
74
78
 
75
- private :terminate
79
+ private AFTER_METHOD
76
80
  end
77
81
 
78
82
  # Sets a user-defined property.
@@ -80,7 +84,7 @@ module RSpec
80
84
  # @example
81
85
  # require "r_spec"
82
86
  #
83
- # RSpec.describe do
87
+ # RSpec.describe "Name stories" do
84
88
  # let(:name) { "Bob" }
85
89
  #
86
90
  # it { expect(name).to eq "Bob" }
@@ -99,9 +103,11 @@ module RSpec
99
103
  # @param name [String, Symbol] The name of the property.
100
104
  # @param block [Proc] The content of the method to define.
101
105
  #
102
- # @return [Symbol] A protected method that define the block content.
106
+ # @return [Symbol] A private method that define the block content.
103
107
  def self.let(name, *args, **kwargs, &block)
104
- protected define_method(name.to_sym, *args, **kwargs, &block)
108
+ raise Error::ReservedMethod if [BEFORE_METHOD, AFTER_METHOD].include?(name.to_sym)
109
+
110
+ private define_method(name, *args, **kwargs, &block)
105
111
  end
106
112
 
107
113
  # Sets a user-defined property named {#subject}.
@@ -140,28 +146,24 @@ module RSpec
140
146
  # # Output to the console
141
147
  # # Success: expected to eq "foobar".
142
148
  #
143
- # @param const [Module, #object_id] A module to include in block context.
149
+ # @param const [Module, String] A module to include in block context.
144
150
  # @param block [Proc] The block to define the specs.
145
- def self.describe(const = nil, &block)
146
- desc = Sandbox.const_set(random_context_const_name, ::Class.new(self))
147
-
148
- if const.is_a?(::Module)
149
- desc.define_method(:described_class) { const }
150
- desc.send(:protected, :described_class)
151
- end
152
-
151
+ def self.describe(const, &block)
152
+ desc = ::Class.new(self)
153
+ desc.let(:described_class) { const } if const.is_a?(::Module)
153
154
  desc.instance_eval(&block)
154
155
  end
155
156
 
156
157
  # Defines an example group that establishes a specific context, like _empty
157
158
  # array_ versus _array with elements_.
158
159
  #
159
- # It is functionally equivalent to {.describe}.
160
+ # Unlike {.describe}, the block is evaluated in isolation in order to scope
161
+ # possible side effects inside its context.
160
162
  #
161
163
  # @example
162
164
  # require "r_spec"
163
165
  #
164
- # RSpec.describe do
166
+ # RSpec.describe "web resource" do
165
167
  # context "when resource is not found" do
166
168
  # pending "responds with 404"
167
169
  # end
@@ -179,8 +181,8 @@ module RSpec
179
181
  # "when", "with" or "without".
180
182
  # @param block [Proc] The block to define the specs.
181
183
  def self.context(_description = nil, &block)
182
- desc = Sandbox.const_set(random_context_const_name, ::Class.new(self))
183
- desc.instance_eval(&block)
184
+ desc = ::Class.new(self)
185
+ ::Aw.fork! { desc.instance_eval(&block) }
184
186
  end
185
187
 
186
188
  # Defines a concrete test case.
@@ -224,14 +226,14 @@ module RSpec
224
226
  def self.it(_name = nil, &block)
225
227
  raise ::ArgumentError, "Missing example block" unless block
226
228
 
227
- i = it_example.new
228
- i.instance_eval(&block)
229
+ example = ::Class.new(self) { include ExpectationHelper::It }.new
230
+ example.instance_eval(&block)
229
231
  rescue ::SystemExit
230
232
  Console.source(*block.source_location)
231
233
 
232
234
  exit false
233
235
  ensure
234
- i.send(:terminate)
236
+ example&.send(AFTER_METHOD)
235
237
  end
236
238
 
237
239
  # Use the {.its} method to define a single spec that specifies the actual
@@ -282,19 +284,21 @@ module RSpec
282
284
  def self.its(attribute, *args, **kwargs, &block)
283
285
  raise ::ArgumentError, "Missing example block" unless block
284
286
 
285
- i = its_example.new
287
+ example = ::Class.new(self) do
288
+ include ExpectationHelper::Its
286
289
 
287
- i.define_singleton_method(:actual) do
288
- subject.public_send(attribute, *args, **kwargs)
289
- end
290
+ define_method(:actual) do
291
+ subject.public_send(attribute, *args, **kwargs)
292
+ end
293
+ end.new
290
294
 
291
- i.instance_eval(&block)
295
+ example.instance_eval(&block)
292
296
  rescue ::SystemExit
293
297
  Console.source(*block.source_location)
294
298
 
295
299
  exit false
296
300
  ensure
297
- i.send(:terminate)
301
+ example&.send(AFTER_METHOD)
298
302
  end
299
303
 
300
304
  # Defines a pending test case.
@@ -305,23 +309,16 @@ module RSpec
305
309
  # @example
306
310
  # require "r_spec"
307
311
  #
308
- # RSpec.describe do
312
+ # RSpec.describe "an example" do
309
313
  # pending "is implemented but waiting" do
310
- # expect("something").to eq("getting finished")
314
+ # expect something to be finished
311
315
  # end
312
- # end
313
316
  #
314
- # # Output to the console
315
- # # Warning: is implemented but waiting.
316
- #
317
- # @example
318
- # require "r_spec"
319
- #
320
- # RSpec.describe do
321
317
  # pending "is not yet implemented and waiting"
322
318
  # end
323
319
  #
324
320
  # # Output to the console
321
+ # # Warning: is implemented but waiting.
325
322
  # # Warning: is not yet implemented and waiting.
326
323
  #
327
324
  # @param message [String] The reason why the example is pending.
@@ -333,30 +330,7 @@ module RSpec
333
330
  Console.passed_spec Error::PendingExpectation.result(message)
334
331
  end
335
332
 
336
- # @private
337
- #
338
- # @return [Class<Dsl>] The class of the example to be tested.
339
- def self.it_example
340
- ::Class.new(self) { include ExpectationHelper::It }
341
- end
342
-
343
- # @private
344
- #
345
- # @return [Class<Dsl>] The class of the example to be tested.
346
- def self.its_example
347
- ::Class.new(self) { include ExpectationHelper::Its }
348
- end
349
-
350
- # @private
351
- #
352
- # @return [String] A random constant name for a test class.
353
- def self.random_context_const_name
354
- "Context#{::SecureRandom.hex(4).to_i(16)}"
355
- end
356
-
357
- private_class_method :it_example, :its_example, :random_context_const_name
358
-
359
- protected
333
+ private
360
334
 
361
335
  def described_class
362
336
  raise Error::UndefinedDescribedClass,
@@ -367,6 +341,8 @@ module RSpec
367
341
  raise Error::UndefinedSubject, "subject not explicitly defined"
368
342
  end
369
343
 
370
- def terminate; end
344
+ define_method(AFTER_METHOD) do
345
+ # do nothing by default
346
+ end
371
347
  end
372
348
  end
data/lib/r_spec/error.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative File.join("error", "pending_expectation")
4
+ require_relative File.join("error", "reserved_method")
4
5
  require_relative File.join("error", "undefined_described_class")
5
6
  require_relative File.join("error", "undefined_subject")
6
7
 
@@ -19,8 +19,7 @@ module RSpec
19
19
  got: false,
20
20
  matcher: :raise_exception,
21
21
  negate: true,
22
- level: :SHOULD,
23
- valid: false
22
+ level: :SHOULD
24
23
  )
25
24
  end
26
25
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Error
5
+ # Exception for reserved methods.
6
+ #
7
+ # @api private
8
+ class ReservedMethod < ::RuntimeError
9
+ end
10
+ end
11
+ end
@@ -4,7 +4,7 @@ require_relative File.join("expectation_helper", "it")
4
4
  require_relative File.join("expectation_helper", "its")
5
5
 
6
6
  module RSpec
7
- # Namespace for `it` and `its` helper modules.
7
+ # Namespace for {Dsl.it} and {Dsl.its}'s helper modules.
8
8
  module ExpectationHelper
9
9
  end
10
10
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "base"
3
+ require_relative "shared"
4
4
  require_relative File.join("..", "expectation_target")
5
5
 
6
6
  module RSpec
7
7
  module ExpectationHelper
8
- # {RSpec::DSL#it}'s expectation helper module.
8
+ # {RSpec::Dsl.it}'s expectation helper module.
9
9
  module It
10
- include Base
10
+ include Shared
11
11
 
12
12
  # Create an expectation for a spec.
13
13
  #
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "base"
3
+ require_relative "shared"
4
4
  require_relative File.join("..", "expectation_target", "block")
5
5
 
6
6
  module RSpec
7
7
  module ExpectationHelper
8
- # {RSpec::DSL#its}'s expectation helper module.
8
+ # {RSpec::Dsl.its}'s expectation helper module.
9
9
  module Its
10
- include Base
10
+ include Shared
11
11
 
12
12
  # Wraps the target of an expectation with the actual value.
13
13
  #
@@ -75,7 +75,7 @@ module RSpec
75
75
  #
76
76
  # @see https://github.com/fixrb/matchi
77
77
  # @see https://github.com/fixrb/matchi-rspec
78
- module Base
78
+ module Shared
79
79
  include ::Matchi::Helper
80
80
  end
81
81
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "expresenter"
4
+ require "test_tube"
4
5
 
5
6
  require_relative File.join("..", "console")
6
7
 
@@ -50,12 +51,12 @@ module RSpec
50
51
 
51
52
  protected
52
53
 
54
+ # @param passed [Boolean] The high expectation passed or failed.
53
55
  # @param actual [#object_id] The actual value.
54
56
  # @param error [Exception, nil] Any raised exception.
55
57
  # @param got [Boolean, nil] Any returned value.
56
58
  # @param matcher [#matches?] The matcher.
57
59
  # @param negate [Boolean] The assertion is positive or negative.
58
- # @param valid [Boolean] The result of an expectation.
59
60
  #
60
61
  # @return [nil] Write a message to STDOUT.
61
62
  #
@@ -63,14 +64,13 @@ module RSpec
63
64
  # `Kernel.exit(false)` with a failure message written to STDERR.
64
65
  #
65
66
  # @api private
66
- def result(actual:, error:, got:, matcher:, negate:, valid:)
67
- Console.passed_spec ::Expresenter.call(valid).with(
67
+ def result(passed, actual:, error:, got:, matcher:, negate:)
68
+ Console.passed_spec ::Expresenter.call(passed).with(
68
69
  actual: actual,
69
70
  error: error,
70
71
  expected: matcher.expected,
71
72
  got: got,
72
73
  negate: negate,
73
- valid: valid,
74
74
  matcher: matcher.class.to_sym,
75
75
  level: :MUST
76
76
  )
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "spectus/exam"
4
-
5
3
  require_relative "base"
6
4
 
7
5
  module RSpec
@@ -30,20 +28,20 @@ module RSpec
30
28
  # @raise [SystemExit] Terminate execution immediately by calling
31
29
  # `Kernel.exit(false)` with a failure message written to STDERR.
32
30
  def absolute_requirement(matcher:, negate:)
33
- exam = ::Spectus::Exam.new(
34
- callable: @actual,
31
+ experiment = ::TestTube.invoke(
32
+ @actual,
35
33
  isolation: false,
36
- negate: negate,
37
- matcher: matcher
34
+ matcher: matcher,
35
+ negate: negate
38
36
  )
39
37
 
40
38
  result(
41
- actual: exam.actual,
42
- error: exam.exception,
43
- got: exam.got,
39
+ experiment.got.equal?(true),
40
+ actual: experiment.actual,
41
+ error: experiment.error,
42
+ got: experiment.got,
44
43
  matcher: matcher,
45
- negate: negate,
46
- valid: exam.valid?
44
+ negate: negate
47
45
  )
48
46
  end
49
47
  end
@@ -28,15 +28,19 @@ module RSpec
28
28
  # @raise [SystemExit] Terminate execution immediately by calling
29
29
  # `Kernel.exit(false)` with a failure message written to STDERR.
30
30
  def absolute_requirement(matcher:, negate:)
31
- valid = negate ^ matcher.matches? { @actual }
31
+ experiment = ::TestTube.pass(
32
+ @actual,
33
+ matcher: matcher,
34
+ negate: negate
35
+ )
32
36
 
33
37
  result(
34
- actual: @actual,
35
- error: nil,
36
- got: valid,
38
+ experiment.got.equal?(true),
39
+ actual: experiment.actual,
40
+ error: experiment.error,
41
+ got: experiment.got,
37
42
  matcher: matcher,
38
- negate: negate,
39
- valid: valid
43
+ negate: negate
40
44
  )
41
45
  end
42
46
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta6
4
+ version: 1.0.0.beta11
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-06-13 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aw
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.12
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.12
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: expresenter
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 1.2.1
33
+ version: 1.3.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 1.2.1
40
+ version: 1.3.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: matchi-rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 1.1.1
47
+ version: 1.1.2
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 1.1.1
54
+ version: 1.1.2
41
55
  - !ruby/object:Gem::Dependency
42
- name: spectus
56
+ name: test_tube
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 3.3.3
61
+ version: 1.1.0
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 3.3.3
68
+ version: 1.1.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -191,17 +205,17 @@ files:
191
205
  - lib/r_spec/dsl.rb
192
206
  - lib/r_spec/error.rb
193
207
  - lib/r_spec/error/pending_expectation.rb
208
+ - lib/r_spec/error/reserved_method.rb
194
209
  - lib/r_spec/error/undefined_described_class.rb
195
210
  - lib/r_spec/error/undefined_subject.rb
196
211
  - lib/r_spec/expectation_helper.rb
197
- - lib/r_spec/expectation_helper/base.rb
198
212
  - lib/r_spec/expectation_helper/it.rb
199
213
  - lib/r_spec/expectation_helper/its.rb
214
+ - lib/r_spec/expectation_helper/shared.rb
200
215
  - lib/r_spec/expectation_target.rb
201
216
  - lib/r_spec/expectation_target/base.rb
202
217
  - lib/r_spec/expectation_target/block.rb
203
218
  - lib/r_spec/expectation_target/value.rb
204
- - lib/r_spec/sandbox.rb
205
219
  homepage: https://r-spec.dev/
206
220
  licenses:
207
221
  - MIT
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpec
4
- # Namespace to collect test classes.
5
- #
6
- # @api private
7
- module Sandbox
8
- end
9
- end