r_spec 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +2 -2
- data/README.md +54 -206
- data/lib/r_spec.rb +3 -165
- metadata +9 -67
- data/lib/r_spec/console.rb +0 -38
- data/lib/r_spec/dsl.rb +0 -348
- data/lib/r_spec/error/pending_expectation.rb +0 -27
- data/lib/r_spec/error/reserved_method.rb +0 -11
- data/lib/r_spec/error/undefined_described_class.rb +0 -11
- data/lib/r_spec/error/undefined_subject.rb +0 -11
- data/lib/r_spec/error.rb +0 -14
- data/lib/r_spec/expectation_helper/it.rb +0 -41
- data/lib/r_spec/expectation_helper/its.rb +0 -25
- data/lib/r_spec/expectation_helper/shared.rb +0 -82
- data/lib/r_spec/expectation_helper.rb +0 -10
- data/lib/r_spec/expectation_target/base.rb +0 -82
- data/lib/r_spec/expectation_target/block.rb +0 -49
- data/lib/r_spec/expectation_target/value.rb +0 -48
- data/lib/r_spec/expectation_target.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d50f4d43bfbae6d44a65b621585a8214ef347e6680cf783ba0983fa5cc39eda2
|
4
|
+
data.tar.gz: 80939bc93d83710a842203b519b25bb5784205477fb8dc6b0672cfaa5282613d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9ad5b0ae0bd629818369e4065fc1191fb81e03f01513bc80fc6fa66f9adfbe16d6ce4147f942b5a8f6a1b9bf9c461c7ef9d63e74363b4c2ff39b77f7819a73
|
7
|
+
data.tar.gz: c9828c3a30f74b6468b137fbe5d03667f3ded7819d7dd08afe09d9fc2274cef3b389226b4d5873de2421f9cb2911941935cb1c378d86a77010565f64d5698c95
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
The MIT License
|
1
|
+
# The MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2015-
|
3
|
+
Copyright (c) 2015-2022 Cyril Kato
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,49 +1,33 @@
|
|
1
1
|
# RSpec clone
|
2
2
|
|
3
|
-
A
|
3
|
+
> A small [RSpec](https://github.com/rspec) clone based on [Fix testing tools for Ruby](https://github.com/fixrb).
|
4
4
|
|
5
|
-
|
5
|
+
***
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
[![Version](https://img.shields.io/github/v/tag/cyril/r_spec.rb?include_prereleases&label=Version&logo=github&sort=semver)](https://github.com/cyril/r_spec.rb/releases)
|
10
|
-
[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?)](https://rubydoc.info/github/cyril/r_spec.rb/main)
|
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
|
-
[![License](https://img.shields.io/github/license/cyril/r_spec.rb?label=License&logo=github)](https://github.com/cyril/r_spec.rb/raw/main/LICENSE.md)
|
7
|
+
:warning: Important:
|
14
8
|
|
15
|
-
|
9
|
+
I'd like to avoid confusion in the Ruby community by emphasizing that the gem of this project is not [rspec](https://rubygems.org/gems/rspec) but [r_spec](https://rubygems.org/gems/r_spec).
|
16
10
|
|
17
|
-
|
18
|
-
* Provide most of RSpec's DSL to express expected outcomes of a code example with no magical powers.
|
11
|
+
The [r_spec](https://rubygems.org/gems/r_spec) gem is a minimalist and personal reimplementation of the popular RSpec framework. My reimplementation is therefore independent of the original RSpec project.
|
19
12
|
|
20
|
-
|
13
|
+
For the purpose of the DSL reimplementation, I have kept the same `RSpec` module name, and following the [Ruby gems naming convention](https://guides.rubygems.org/name-your-gem/#use-underscores-for-multiple-words), I called its gem [r_spec](https://rubygems.org/gems/r_spec).
|
21
14
|
|
22
|
-
|
23
|
-
* Spec files can also be executed directly with the `ruby` executable.
|
24
|
-
* There is no option to activate monkey-patching.
|
25
|
-
* It does not rely on hacks such as `at_exit` hook to trigger the tests.
|
26
|
-
* Built-in matchers [do not trust _actual_](https://asciinema.org/a/29172?autoplay=1&speed=2) and do not send it messages.
|
27
|
-
* If no `subject` has been explicitly determined, none is defined.
|
28
|
-
* If no described class is set, `described_class` is undefined instead of `nil`.
|
29
|
-
* Expectations cannot be added inside a `before` block.
|
30
|
-
* [Arbitrary helper methods](https://relishapp.com/rspec/rspec-core/v/3-10/docs/helper-methods/arbitrary-helper-methods) are not exposed to examples.
|
31
|
-
* The `let` method defines a helper method rather than a memoized helper method.
|
32
|
-
* The one-liner `is_expected` syntax also works with block expectations.
|
33
|
-
* `subject`, `before`, `after` and `let` definitions must come before examples.
|
34
|
-
* Each [`context` runs its tests in _isolation_](https://asciinema.org/a/29070?autoplay=1&speed=2) to prevent side effects.
|
15
|
+
However, to go further and explicitly indicate that this reimplementation is a clone, I have grouped all the code in a `RSpec::Clone` submodule within its [r_spec-clone](https://rubygems.org/gems/r_spec-clone) gem.
|
35
16
|
|
36
|
-
|
17
|
+
***
|
37
18
|
|
38
|
-
|
19
|
+
## Status
|
39
20
|
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
[![Home](https://img.shields.io/badge/Home-r--spec.dev-00af8b)](https://r-spec.dev/)
|
22
|
+
[![Version](https://img.shields.io/github/v/tag/cyril/r_spec.rb?label=Version&logo=github)](https://github.com/cyril/r_spec.rb/releases)
|
23
|
+
[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/cyril/r_spec.rb/main)
|
24
|
+
[![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)
|
25
|
+
[![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)
|
26
|
+
[![License](https://img.shields.io/github/license/cyril/r_spec.rb?label=License&logo=github)](https://github.com/cyril/r_spec.rb/raw/main/LICENSE.md)
|
43
27
|
|
44
|
-
|
28
|
+
## Why did I redid that?
|
45
29
|
|
46
|
-
|
30
|
+
An urge to simplify the RSpec DSL and reduce the complexity of the code that implements it, and nothing better to do during a stay in Tokyo.
|
47
31
|
|
48
32
|
## Installation
|
49
33
|
|
@@ -56,7 +40,7 @@ gem "r_spec"
|
|
56
40
|
And then execute:
|
57
41
|
|
58
42
|
```sh
|
59
|
-
bundle
|
43
|
+
bundle install
|
60
44
|
```
|
61
45
|
|
62
46
|
Or install it yourself as:
|
@@ -65,204 +49,68 @@ Or install it yourself as:
|
|
65
49
|
gem install r_spec
|
66
50
|
```
|
67
51
|
|
68
|
-
##
|
69
|
-
|
70
|
-
__RSpec clone__ provides a structure for writing executable examples of how your code should behave.
|
71
|
-
|
72
|
-
Inspired by [RSpec](https://rspec.info/), it includes a domain specific language (DSL) that allows you to write examples in a way similar to plain english.
|
73
|
-
|
74
|
-
A basic spec looks something like this:
|
75
|
-
|
76
|
-
[![RSpec clone demo](https://asciinema.org/a/422210.svg)](https://asciinema.org/a/422210?autoplay=1&speed=2)
|
77
|
-
|
78
|
-
## Usage
|
79
|
-
|
80
|
-
### Anatomy of a spec file
|
81
|
-
|
82
|
-
To use the `RSpec` module and its DSL, you need to add `require "r_spec"` to your spec files.
|
83
|
-
Many projects use a custom spec helper which organizes these includes.
|
84
|
-
|
85
|
-
Concrete test cases are defined in `it` blocks.
|
86
|
-
An optional descriptive string states it's purpose and a block contains the main logic performing the test.
|
87
|
-
|
88
|
-
Test cases that have been defined or outlined but are not yet expected to work can be defined using `pending` instead of `it`. They will not be run but show up in the spec report as pending.
|
89
|
-
|
90
|
-
An `it` block contains an example that should invoke the code to be tested and define what is expected of it.
|
91
|
-
Each example can contain multiple expectations, but it should test only one specific behaviour.
|
92
|
-
|
93
|
-
To express an expectation, wrap an object or block in `expect`, call `to` (or `not_to`) and pass it a matcher object.
|
94
|
-
If the expectation is met, code execution continues.
|
95
|
-
Otherwise the example has _failed_ and other code will not be executed.
|
96
|
-
|
97
|
-
In test files, specs are structured by example groups which are defined by `describe` and `context` sections.
|
98
|
-
Typically a top level `describe` defines the outer unit (such as a class) to be tested by the spec.
|
99
|
-
Further `describe` sections can be nested within the outer unit to specify smaller units under test (such as individual methods).
|
100
|
-
|
101
|
-
For unit tests, it is recommended to follow the conventions for method names:
|
102
|
-
|
103
|
-
* outer `describe` is the name of the class, inner `describe` targets methods;
|
104
|
-
* instance methods are prefixed with `#`, class methods with `.`.
|
105
|
-
|
106
|
-
To establish certain contexts — think _empty array_ versus _array with elements_ — the `context` method may be used to communicate this to the reader.
|
107
|
-
Its behavior is slightly different from `describe` because each `context` runs its tests in isolation,
|
108
|
-
so side effects caused by testing do not propagate out of contexts.
|
109
|
-
|
110
|
-
`describe` and `context` take an optional description as argument and a block containing the individual specs or nested groupings.
|
111
|
-
|
112
|
-
### Expectations
|
113
|
-
|
114
|
-
Expectations define if the value being tested (_actual_) matches a certain value or specific criteria.
|
115
|
-
|
116
|
-
#### Equivalence
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
expect(actual).to eql(expected) # passes if expected.eql?(actual)
|
120
|
-
expect(actual).to eq(expected) # passes if expected.eql?(actual)
|
121
|
-
```
|
122
|
-
|
123
|
-
#### Identity
|
124
|
-
|
125
|
-
```ruby
|
126
|
-
expect(actual).to equal(expected) # passes if expected.equal?(actual)
|
127
|
-
expect(actual).to be(expected) # passes if expected.equal?(actual)
|
128
|
-
```
|
129
|
-
|
130
|
-
#### Regular expressions
|
131
|
-
|
132
|
-
```ruby
|
133
|
-
expect(actual).to match(expected) # passes if expected.match?(actual)
|
134
|
-
```
|
135
|
-
|
136
|
-
#### Expecting errors
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
expect { actual }.to raise_exception(expected) # passes if expected exception is raised
|
140
|
-
```
|
141
|
-
|
142
|
-
#### Truth
|
52
|
+
## GitHub repo
|
143
53
|
|
144
|
-
|
145
|
-
expect(actual).to be_true # passes if true.equal?(actual)
|
146
|
-
```
|
54
|
+
All the code is centralized in the `RSpec::Clone` module, whose source code is versioned at <https://github.com/cyril/r_spec-clone.rb>.
|
147
55
|
|
148
|
-
|
56
|
+
## "`Hello, World!`" example
|
149
57
|
|
150
|
-
|
151
|
-
expect(actual).to be_false # passes if false.equal?(actual)
|
152
|
-
```
|
153
|
-
|
154
|
-
#### Nil
|
58
|
+
Let's imagine a `string_hello_world_spec.rb` file that contains this code:
|
155
59
|
|
156
60
|
```ruby
|
157
|
-
|
158
|
-
```
|
61
|
+
# frozen_string_literal: false
|
159
62
|
|
160
|
-
|
63
|
+
require "r_spec"
|
161
64
|
|
162
|
-
|
163
|
-
expect(actual).to be_instance_of(expected) # passes if expected.equal?(actual.class)
|
164
|
-
expect(actual).to be_an_instance_of(expected) # passes if expected.equal?(actual.class)
|
165
|
-
```
|
65
|
+
app = "Hello, World!"
|
166
66
|
|
167
|
-
|
67
|
+
RSpec.describe String do
|
68
|
+
subject do
|
69
|
+
app
|
70
|
+
end
|
168
71
|
|
169
|
-
|
72
|
+
before do
|
73
|
+
subject.gsub!("World", friend)
|
74
|
+
end
|
170
75
|
|
171
|
-
|
172
|
-
|
76
|
+
context "when Alice is greeted" do
|
77
|
+
let(:friend) { "Alice" }
|
173
78
|
|
174
|
-
|
79
|
+
it { is_expected.to eq "Hello, Alice!" }
|
80
|
+
end
|
175
81
|
|
176
|
-
|
82
|
+
context "when Bob is greeted" do
|
83
|
+
let(:friend) { "Bob" }
|
177
84
|
|
178
|
-
|
179
|
-
|
85
|
+
it { is_expected.to eq "Hello, Bob!" }
|
86
|
+
end
|
87
|
+
end
|
180
88
|
```
|
181
89
|
|
182
|
-
|
90
|
+
We can run it with Ruby:
|
183
91
|
|
184
92
|
```sh
|
185
|
-
ruby
|
93
|
+
ruby string_hello_world_spec.rb
|
186
94
|
```
|
187
95
|
|
188
|
-
|
96
|
+
The report of the execution should be:
|
189
97
|
|
190
|
-
```
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
98
|
+
```txt
|
99
|
+
string_hello_world_spec.rb:19
|
100
|
+
Success: expected to eq "Hello, Alice!".
|
101
|
+
string_hello_world_spec.rb:25
|
102
|
+
Success: expected to eq "Hello, Bob!".
|
195
103
|
```
|
196
104
|
|
197
|
-
|
198
|
-
|
199
|
-
Many projects use a custom spec helper file, usually named `spec/spec_helper.rb`.
|
200
|
-
|
201
|
-
This file is used to require `r_spec` and other includes, like the code from the project needed for every spec file.
|
105
|
+
## External links
|
202
106
|
|
203
|
-
|
204
|
-
|
205
|
-
The following `Rakefile` settings should be enough:
|
206
|
-
|
207
|
-
```ruby
|
208
|
-
require "bundler/gem_tasks"
|
209
|
-
require "rake/testtask"
|
210
|
-
|
211
|
-
Rake::TestTask.new do |t|
|
212
|
-
t.pattern = "spec/**/*_spec.rb"
|
213
|
-
t.verbose = true
|
214
|
-
t.warning = true
|
215
|
-
end
|
216
|
-
|
217
|
-
task spec: :test
|
218
|
-
task default: :test
|
219
|
-
```
|
220
|
-
|
221
|
-
## Performance
|
222
|
-
|
223
|
-
### Runtime
|
224
|
-
|
225
|
-
Benchmark against [100 executions of a file containing one expectation](https://github.com/cyril/r_spec.rb/blob/main/benchmark/) (lower is better).
|
226
|
-
|
227
|
-
![Runtime](https://r-spec.dev/benchmark-runtime.png)
|
228
|
-
|
229
|
-
## Test suite
|
230
|
-
|
231
|
-
__RSpec clone__'s specifications are self-described here: [spec/](https://github.com/cyril/r_spec.rb/blob/main/spec/)
|
232
|
-
|
233
|
-
## Contact
|
234
|
-
|
235
|
-
* Home page: [https://r-spec.dev/](https://r-spec.dev/)
|
236
|
-
* Cheatsheet: [https://r-spec.dev/cheatsheet.html](https://r-spec.dev/cheatsheet.html)
|
237
|
-
* Source code: [https://github.com/cyril/r_spec.rb](https://github.com/cyril/r_spec.rb)
|
238
|
-
* API Doc: [https://rubydoc.info/gems/r_spec](https://rubydoc.info/gems/r_spec)
|
239
|
-
* Twitter: [https://twitter.com/cyri\_](https://twitter.com/cyri\_)
|
240
|
-
|
241
|
-
## Special thanks ❤️
|
242
|
-
|
243
|
-
I would like to thank the whole [RSpec team](https://rspec.info/about/) for all their work.
|
244
|
-
It's a great framework and it's a pleasure to work with every day.
|
245
|
-
|
246
|
-
Without RSpec, this clone would not have been possible.
|
247
|
-
|
248
|
-
## Buy me a coffee ☕
|
249
|
-
|
250
|
-
If you like this project please consider making a small donation.
|
251
|
-
|
252
|
-
[![Donate with Ethereum](https://github.com/cyril/r_spec.rb/raw/main/img/donate-eth.svg)](https://etherscan.io/address/0x834b5c1feaff5aebf9cd0f25dc38e741d65ab773)
|
107
|
+
* [Official RSpec project](https://rspec.info/)
|
108
|
+
* [Personal RSpec reimplementation](https://r-spec.dev/)
|
253
109
|
|
254
110
|
## Versioning
|
255
111
|
|
256
|
-
|
112
|
+
__RSpec__ uses [Semantic Versioning 2.0.0](https://semver.org/)
|
257
113
|
|
258
114
|
## License
|
259
115
|
|
260
|
-
The [gem](https://rubygems.org/gems/r_spec) is available as open source under the terms of the [MIT License](https://
|
261
|
-
|
262
|
-
## One more thing
|
263
|
-
|
264
|
-
Under the hood, __RSpec clone__ is largely animated by [a collection of testing libraries designed to make programmers happy](https://github.com/fixrb/).
|
265
|
-
|
266
|
-
It's a living example of what we can do combining small libraries together that can boost the fun of programming.
|
267
|
-
|
268
|
-
![Fix testing tools logo for Ruby](https://github.com/cyril/r_spec.rb/raw/main/img/fixrb.svg)
|
116
|
+
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).
|
data/lib/r_spec.rb
CHANGED
@@ -1,170 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative File.join("r_spec", "dsl")
|
4
|
-
|
5
3
|
# Top level namespace for the RSpec clone.
|
6
|
-
#
|
7
|
-
# @example The true from the false
|
8
|
-
# require "r_spec"
|
9
|
-
#
|
10
|
-
# RSpec.describe "The true from the false" do
|
11
|
-
# it { expect(false).not_to be true }
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# # Output to the console
|
15
|
-
# # Success: expected false not to be true.
|
16
|
-
#
|
17
|
-
# @example The basic behavior of arrays
|
18
|
-
# require "r_spec"
|
19
|
-
#
|
20
|
-
# RSpec.describe Array do
|
21
|
-
# describe "#size" do
|
22
|
-
# it "correctly reports the number of elements in the Array" do
|
23
|
-
# expect([1, 2, 3].size).to eq 3
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# describe "#empty?" do
|
28
|
-
# it "is empty when no elements are in the array" do
|
29
|
-
# expect([].empty?).to be_true
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
# it "is not empty if there are elements in the array" do
|
33
|
-
# expect([1].empty?).to be_false
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# # Output to the console
|
39
|
-
# # Success: expected to eq 3.
|
40
|
-
# # Success: expected true to be true.
|
41
|
-
# # Success: expected false to be false.
|
42
|
-
#
|
43
|
-
# @example An inherited definition of let
|
44
|
-
# require "r_spec"
|
45
|
-
#
|
46
|
-
# RSpec.describe Integer do
|
47
|
-
# let(:answer) { 42 }
|
48
|
-
#
|
49
|
-
# it "returns the value" do
|
50
|
-
# expect(answer).to be(42)
|
51
|
-
# end
|
52
|
-
#
|
53
|
-
# context "when the number is incremented" do
|
54
|
-
# let(:answer) { super().next }
|
55
|
-
#
|
56
|
-
# it "returns the next value" do
|
57
|
-
# expect(answer).to be(43)
|
58
|
-
# end
|
59
|
-
# end
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# # Output to the console
|
63
|
-
# # Success: expected to be 42.
|
64
|
-
# # Success: expected to be 43.
|
65
|
-
#
|
66
|
-
# @api public
|
4
|
+
# @see https://github.com/cyril/r_spec-clone.rb
|
67
5
|
module RSpec
|
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".
|
108
|
-
#
|
109
|
-
# @param const [Module, String] A module to include in block context.
|
110
|
-
# @param block [Proc] The block to define the specs.
|
111
|
-
#
|
112
|
-
# @api public
|
113
|
-
def self.describe(const, &block)
|
114
|
-
Dsl.describe(const, &block)
|
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
|
170
6
|
end
|
7
|
+
|
8
|
+
require "r_spec/clone"
|
metadata
CHANGED
@@ -1,71 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: r_spec-clone
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
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
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: expresenter
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.3.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: matchi-rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.1.2
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.1.2
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: test_tube
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
17
|
+
- - ">="
|
60
18
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
19
|
+
version: '0'
|
62
20
|
type: :runtime
|
63
21
|
prerelease: false
|
64
22
|
version_requirements: !ruby/object:Gem::Requirement
|
65
23
|
requirements:
|
66
|
-
- - "
|
24
|
+
- - ">="
|
67
25
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
26
|
+
version: '0'
|
69
27
|
- !ruby/object:Gem::Dependency
|
70
28
|
name: bundler
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,29 +159,13 @@ files:
|
|
201
159
|
- LICENSE.md
|
202
160
|
- README.md
|
203
161
|
- lib/r_spec.rb
|
204
|
-
- lib/r_spec/console.rb
|
205
|
-
- lib/r_spec/dsl.rb
|
206
|
-
- lib/r_spec/error.rb
|
207
|
-
- lib/r_spec/error/pending_expectation.rb
|
208
|
-
- lib/r_spec/error/reserved_method.rb
|
209
|
-
- lib/r_spec/error/undefined_described_class.rb
|
210
|
-
- lib/r_spec/error/undefined_subject.rb
|
211
|
-
- lib/r_spec/expectation_helper.rb
|
212
|
-
- lib/r_spec/expectation_helper/it.rb
|
213
|
-
- lib/r_spec/expectation_helper/its.rb
|
214
|
-
- lib/r_spec/expectation_helper/shared.rb
|
215
|
-
- lib/r_spec/expectation_target.rb
|
216
|
-
- lib/r_spec/expectation_target/base.rb
|
217
|
-
- lib/r_spec/expectation_target/block.rb
|
218
|
-
- lib/r_spec/expectation_target/value.rb
|
219
162
|
homepage: https://r-spec.dev/
|
220
163
|
licenses:
|
221
164
|
- MIT
|
222
165
|
metadata:
|
223
166
|
bug_tracker_uri: https://github.com/cyril/r_spec.rb/issues
|
224
|
-
documentation_uri: https://rubydoc.info/gems/r_spec
|
225
167
|
source_code_uri: https://github.com/cyril/r_spec.rb
|
226
|
-
|
168
|
+
rubygems_mfa_required: 'true'
|
227
169
|
post_install_message:
|
228
170
|
rdoc_options: []
|
229
171
|
require_paths:
|
@@ -239,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
181
|
- !ruby/object:Gem::Version
|
240
182
|
version: '0'
|
241
183
|
requirements: []
|
242
|
-
rubygems_version: 3.1.
|
184
|
+
rubygems_version: 3.1.2
|
243
185
|
signing_key:
|
244
186
|
specification_version: 4
|
245
187
|
summary: A minimalist RSpec clone
|
data/lib/r_spec/console.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
# Send log messages to the console.
|
5
|
-
#
|
6
|
-
# @api private
|
7
|
-
module Console
|
8
|
-
# @param report [::Expresenter::Pass] Passed expectation result presenter.
|
9
|
-
#
|
10
|
-
# @see https://github.com/fixrb/expresenter
|
11
|
-
#
|
12
|
-
# @return [nil] Add a colored message to `$stdout`.
|
13
|
-
def self.passed_spec(report)
|
14
|
-
puts report.colored_string
|
15
|
-
end
|
16
|
-
|
17
|
-
# @param report [::Expresenter::Fail] Failed expectation result presenter.
|
18
|
-
#
|
19
|
-
# @see https://github.com/fixrb/expresenter
|
20
|
-
#
|
21
|
-
# @raise [SystemExit] Terminate execution immediately with colored message.
|
22
|
-
def self.failed_spec(report)
|
23
|
-
abort report.colored_string
|
24
|
-
end
|
25
|
-
|
26
|
-
# The Ruby source filename and line number containing this method or nil if
|
27
|
-
# this method was not defined in Ruby (i.e. native).
|
28
|
-
#
|
29
|
-
# @param filename [String, nil] The Ruby source filename.
|
30
|
-
# @param line [Integer, nil] The Ruby source line number.
|
31
|
-
#
|
32
|
-
# @return [String] The Ruby source filename and line number associated with
|
33
|
-
# the evaluated spec.
|
34
|
-
def self.source(filename, line)
|
35
|
-
puts [filename, line].compact.join(":")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|