r_spec 1.0.0.beta10 → 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 +4 -4
- data/README.md +11 -11
- data/lib/r_spec.rb +40 -1
- data/lib/r_spec/dsl.rb +5 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7957c4316cd89f58118ce544d50f3b5f401962648415b535c97da57ae4b7db
|
4
|
+
data.tar.gz: a1e8ec62ac5d695203917c85674a1d9b5dccbf1993c4fb55569fdd9d9401220b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51375c2f10d7cc11e71041c538940956e94721ae8f6e72af2bbb770d0b73041f6845b0100e9ebec2f7ec5d178fef388d5a5ece60e41076d7ff659d1d035afabd
|
7
|
+
data.tar.gz: 512ec78cc25d9ec8e0b5661c9a14b1fae3ae73714d8dc21e291721277ee6741035f5ccf130e190d661e8b19caf5d356d603a9951b40ad74b7fbdd20f7f9e6fec
|
data/README.md
CHANGED
@@ -7,8 +7,9 @@ A minimalist __[RSpec](https://github.com/rspec/rspec) clone__ with all the esse
|
|
7
7
|
## Status
|
8
8
|
|
9
9
|
[](https://badge.fury.io/rb/r_spec)
|
10
|
-
[](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Aci+branch%3Amain)
|
11
10
|
[](https://rubydoc.info/gems/r_spec/frames)
|
11
|
+
[](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Aci+branch%3Amain)
|
12
|
+
[](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Arubocop+branch%3Amain)
|
12
13
|
|
13
14
|
## Project goals
|
14
15
|
|
@@ -29,6 +30,7 @@ A minimalist __[RSpec](https://github.com/rspec/rspec) clone__ with all the esse
|
|
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.
|
31
32
|
* `subject`, `before`, `after` and `let` definitions must come before examples.
|
33
|
+
* Each `context` runs its tests in _isolation_ to prevent side effects.
|
32
34
|
|
33
35
|
## Important ⚠️
|
34
36
|
|
@@ -47,7 +49,7 @@ Following [RubyGems naming conventions](https://guides.rubygems.org/name-your-ge
|
|
47
49
|
Add this line to your application's Gemfile:
|
48
50
|
|
49
51
|
```ruby
|
50
|
-
gem "r_spec", ">= 1.0.0.
|
52
|
+
gem "r_spec", ">= 1.0.0.beta11"
|
51
53
|
```
|
52
54
|
|
53
55
|
And then execute:
|
@@ -101,7 +103,8 @@ For unit tests, it is recommended to follow the conventions for method names:
|
|
101
103
|
* instance methods are prefixed with `#`, class methods with `.`.
|
102
104
|
|
103
105
|
To establish certain contexts — think _empty array_ versus _array with elements_ — the `context` method may be used to communicate this to the reader.
|
104
|
-
|
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.
|
105
108
|
|
106
109
|
`describe` and `context` take an optional description as argument and a block containing the individual specs or nested groupings.
|
107
110
|
|
@@ -220,12 +223,7 @@ task default: :test
|
|
220
223
|
|
221
224
|
Benchmark against [100 executions of a file containing one expectation](https://github.com/cyril/r_spec.rb/blob/main/benchmark/) (lower is better).
|
222
225
|
|
223
|
-
|
224
|
-
|-------------|---------------------|
|
225
|
-
| `r_spec` | 13.0 |
|
226
|
-
| `rspec` | 32.2 |
|
227
|
-
| `minitest` | 17.5 |
|
228
|
-
| `test-unit` | 20.5 |
|
226
|
+

|
229
227
|
|
230
228
|
## Test suite
|
231
229
|
|
@@ -233,8 +231,10 @@ __RSpec clone__'s specifications are self-described here: [spec/](https://github
|
|
233
231
|
|
234
232
|
## Contact
|
235
233
|
|
236
|
-
* Home page: https://r-spec.dev
|
237
|
-
*
|
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)
|
238
238
|
* Twitter: [https://twitter.com/cyri\_](https://twitter.com/cyri\_)
|
239
239
|
|
240
240
|
## Special thanks ❤️
|
data/lib/r_spec.rb
CHANGED
@@ -65,7 +65,46 @@ require_relative File.join("r_spec", "dsl")
|
|
65
65
|
#
|
66
66
|
# @api public
|
67
67
|
module RSpec
|
68
|
-
#
|
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.
|
data/lib/r_spec/dsl.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "aw"
|
4
|
+
|
3
5
|
require_relative "console"
|
4
6
|
require_relative "error"
|
5
7
|
require_relative "expectation_helper"
|
@@ -155,7 +157,8 @@ module RSpec
|
|
155
157
|
# Defines an example group that establishes a specific context, like _empty
|
156
158
|
# array_ versus _array with elements_.
|
157
159
|
#
|
158
|
-
#
|
160
|
+
# Unlike {.describe}, the block is evaluated in isolation in order to scope
|
161
|
+
# possible side effects inside its context.
|
159
162
|
#
|
160
163
|
# @example
|
161
164
|
# require "r_spec"
|
@@ -179,7 +182,7 @@ module RSpec
|
|
179
182
|
# @param block [Proc] The block to define the specs.
|
180
183
|
def self.context(_description = nil, &block)
|
181
184
|
desc = ::Class.new(self)
|
182
|
-
desc.instance_eval(&block)
|
185
|
+
::Aw.fork! { desc.instance_eval(&block) }
|
183
186
|
end
|
184
187
|
|
185
188
|
# Defines a concrete test case.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
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-
|
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
|