r_spec 1.0.0.beta11 → 1.0.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/LICENSE.md +2 -2
- data/README.md +54 -208
- data/lib/r_spec.rb +3 -165
- metadata +12 -70
- 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: 07a1c8219cd7741811c7d89f5df7eba78b3bdc1ff33e08ca4d254c25d9787b7e
|
4
|
+
data.tar.gz: bc3e131d7934aa091b03d7bbd258afb69f1aaa53ef1cec1661a1f4580589209d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8f167f145ade88ba9c45c3e744034c69145068a5fb42653cd52a6d068214c36da8160c447f993d07483bb76340a540e4917c26af29802178111c09fcc2e7e26
|
7
|
+
data.tar.gz: c3a8c57f1744d88d54640077e68be99a614b22d695830a3a1572b4a45ad900943879ccb5286de7cfd426d2b171d6916a102d30018a6e035edceb2032a184424f
|
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,267 +1,113 @@
|
|
1
|
-
# RSpec clone
|
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
|
-
[](https://badge.fury.io/rb/r_spec)
|
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)
|
7
|
+
:warning: Important:
|
13
8
|
|
14
|
-
|
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).
|
15
10
|
|
16
|
-
|
17
|
-
* Provide most of RSpec's DSL to express expected outcomes of a code example without magic power.
|
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.
|
18
12
|
|
19
|
-
|
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).
|
20
14
|
|
21
|
-
|
22
|
-
* Spec files can also be executed directly with the `ruby` executable.
|
23
|
-
* There is no option to activate monkey-patching.
|
24
|
-
* It does not rely on hacks such as `at_exit` hook to trigger the tests.
|
25
|
-
* Built-in matchers do not trust _actual_ and do not send it messages.
|
26
|
-
* If no `subject` has been explicitly determined, none is defined.
|
27
|
-
* If no described class is set, `described_class` is undefined instead of `nil`.
|
28
|
-
* Expectations cannot be added inside a `before` block.
|
29
|
-
* [Arbitrary helper methods](https://relishapp.com/rspec/rspec-core/v/3-10/docs/helper-methods/arbitrary-helper-methods) are not exposed to examples.
|
30
|
-
* The `let` method defines a helper method rather than a memoized helper method.
|
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.
|
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.
|
34
16
|
|
35
|
-
|
17
|
+
***
|
36
18
|
|
37
|
-
|
19
|
+
## Status
|
38
20
|
|
39
|
-
|
40
|
-
|
41
|
-
|
21
|
+
[](https://github.com/cyril/r_spec.rb/releases)
|
22
|
+
[](https://rubydoc.info/github/cyril/r_spec.rb/main)
|
23
|
+
[](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Aci+branch%3Amain)
|
24
|
+
[](https://github.com/cyril/r_spec.rb/actions?query=workflow%3Arubocop+branch%3Amain)
|
25
|
+
[](https://github.com/cyril/r_spec.rb/raw/main/LICENSE.md)
|
42
26
|
|
43
|
-
|
27
|
+
## Why did I redid that?
|
44
28
|
|
45
|
-
|
29
|
+
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.
|
46
30
|
|
47
31
|
## Installation
|
48
32
|
|
49
33
|
Add this line to your application's Gemfile:
|
50
34
|
|
51
35
|
```ruby
|
52
|
-
gem "r_spec"
|
36
|
+
gem "r_spec"
|
53
37
|
```
|
54
38
|
|
55
39
|
And then execute:
|
56
40
|
|
57
41
|
```sh
|
58
|
-
bundle
|
42
|
+
bundle install
|
59
43
|
```
|
60
44
|
|
61
45
|
Or install it yourself as:
|
62
46
|
|
63
47
|
```sh
|
64
|
-
gem install r_spec
|
48
|
+
gem install r_spec
|
65
49
|
```
|
66
50
|
|
67
|
-
##
|
68
|
-
|
69
|
-
__RSpec clone__ provides a structure for writing executable examples of how your code should behave.
|
70
|
-
|
71
|
-
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.
|
72
|
-
|
73
|
-
A basic spec looks something like this:
|
74
|
-
|
75
|
-
[](https://asciinema.org/a/418672?autoplay=1)
|
76
|
-
|
77
|
-
## Usage
|
78
|
-
|
79
|
-
### Anatomy of a spec file
|
80
|
-
|
81
|
-
To use the `RSpec` module and its DSL, you need to add `require "r_spec"` to your spec files.
|
82
|
-
Many projects use a custom spec helper which organizes these includes.
|
83
|
-
|
84
|
-
Concrete test cases are defined in `it` blocks.
|
85
|
-
An optional descriptive string states it's purpose and a block contains the main logic performing the test.
|
86
|
-
|
87
|
-
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.
|
88
|
-
|
89
|
-
An `it` block contains an example that should invoke the code to be tested and define what is expected of it.
|
90
|
-
Each example can contain multiple expectations, but it should test only one specific behaviour.
|
91
|
-
|
92
|
-
To express an expectation, wrap an object or block in `expect`, call `to` (or `not_to`) and pass it a matcher object.
|
93
|
-
If the expectation is met, code execution continues.
|
94
|
-
Otherwise the example has _failed_ and other code will not be executed.
|
95
|
-
|
96
|
-
In test files, specs are structured by example groups which are defined by `describe` and `context` sections.
|
97
|
-
Typically a top level `describe` defines the outer unit (such as a class) to be tested by the spec.
|
98
|
-
Further `describe` sections can be nested within the outer unit to specify smaller units under test (such as individual methods).
|
99
|
-
|
100
|
-
For unit tests, it is recommended to follow the conventions for method names:
|
101
|
-
|
102
|
-
* outer `describe` is the name of the class, inner `describe` targets methods;
|
103
|
-
* instance methods are prefixed with `#`, class methods with `.`.
|
51
|
+
## GitHub repo
|
104
52
|
|
105
|
-
|
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.
|
53
|
+
All the code is centralized in the `RSpec::Clone` module, whose source code is versioned at <https://github.com/cyril/r_spec-clone.rb>.
|
108
54
|
|
109
|
-
|
55
|
+
## "`Hello, World!`" example
|
110
56
|
|
111
|
-
|
112
|
-
|
113
|
-
Expectations define if the value being tested (_actual_) matches a certain value or specific criteria.
|
114
|
-
|
115
|
-
#### Equivalence
|
116
|
-
|
117
|
-
```ruby
|
118
|
-
expect(actual).to eql(expected) # passes if expected.eql?(actual)
|
119
|
-
expect(actual).to eq(expected) # passes if expected.eql?(actual)
|
120
|
-
```
|
121
|
-
|
122
|
-
#### Identity
|
123
|
-
|
124
|
-
```ruby
|
125
|
-
expect(actual).to equal(expected) # passes if expected.equal?(actual)
|
126
|
-
expect(actual).to be(expected) # passes if expected.equal?(actual)
|
127
|
-
```
|
128
|
-
|
129
|
-
#### Regular expressions
|
57
|
+
Let's imagine a `string_hello_world_spec.rb` file that contains this code:
|
130
58
|
|
131
59
|
```ruby
|
132
|
-
|
133
|
-
```
|
60
|
+
# frozen_string_literal: false
|
134
61
|
|
135
|
-
|
62
|
+
require "r_spec"
|
136
63
|
|
137
|
-
|
138
|
-
expect { actual }.to raise_exception(expected) # passes if expected exception is raised
|
139
|
-
```
|
64
|
+
app = "Hello, World!"
|
140
65
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
```
|
66
|
+
RSpec.describe String do
|
67
|
+
subject do
|
68
|
+
app
|
69
|
+
end
|
146
70
|
|
147
|
-
|
71
|
+
before do
|
72
|
+
subject.gsub!("World", friend)
|
73
|
+
end
|
148
74
|
|
149
|
-
|
150
|
-
|
151
|
-
```
|
75
|
+
context "when Alice is greeted" do
|
76
|
+
let(:friend) { "Alice" }
|
152
77
|
|
153
|
-
|
78
|
+
it { is_expected.to eq "Hello, Alice!" }
|
79
|
+
end
|
154
80
|
|
155
|
-
|
156
|
-
|
157
|
-
```
|
81
|
+
context "when Bob is greeted" do
|
82
|
+
let(:friend) { "Bob" }
|
158
83
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
expect(actual).to be_instance_of(expected) # passes if expected.equal?(actual.class)
|
163
|
-
expect(actual).to be_an_instance_of(expected) # passes if expected.equal?(actual.class)
|
164
|
-
```
|
165
|
-
|
166
|
-
### Running specs
|
167
|
-
|
168
|
-
By convention, specs live in the `spec/` directory of a project. Spec files should end with `_spec.rb` to be recognizable as such.
|
169
|
-
|
170
|
-
Depending of the project settings, you may run the specs of a project by running `rake spec` (see [`rake` integration example](#rake-integration-example) below).
|
171
|
-
A single file can also be executed directly with the Ruby interpreter.
|
172
|
-
|
173
|
-
#### Examples
|
174
|
-
|
175
|
-
Run all specs in files matching `spec/**/*_spec.rb`:
|
176
|
-
|
177
|
-
```sh
|
178
|
-
bundle exec rake spec
|
179
|
-
```
|
180
|
-
|
181
|
-
Run a single file:
|
182
|
-
|
183
|
-
```sh
|
184
|
-
ruby spec/my/test/file_spec.rb
|
84
|
+
it { is_expected.to eq "Hello, Bob!" }
|
85
|
+
end
|
86
|
+
end
|
185
87
|
```
|
186
88
|
|
187
|
-
|
89
|
+
We can run it with Ruby:
|
188
90
|
|
189
91
|
```sh
|
190
|
-
|
191
|
-
rspec spec/my/test/file_spec.rb:42
|
192
|
-
rspec spec/my/test/
|
193
|
-
rspec
|
194
|
-
```
|
195
|
-
|
196
|
-
### Spec helper
|
197
|
-
|
198
|
-
Many projects use a custom spec helper file, usually named `spec/spec_helper.rb`.
|
199
|
-
|
200
|
-
This file is used to require `r_spec` and other includes, like the code from the project needed for every spec file.
|
201
|
-
|
202
|
-
### `rake` integration example
|
203
|
-
|
204
|
-
The following `Rakefile` settings should be enough:
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
require "bundler/gem_tasks"
|
208
|
-
require "rake/testtask"
|
209
|
-
|
210
|
-
Rake::TestTask.new do |t|
|
211
|
-
t.pattern = "spec/**/*_spec.rb"
|
212
|
-
t.verbose = true
|
213
|
-
t.warning = true
|
214
|
-
end
|
215
|
-
|
216
|
-
task spec: :test
|
217
|
-
task default: :test
|
92
|
+
ruby string_hello_world_spec.rb
|
218
93
|
```
|
219
94
|
|
220
|
-
|
221
|
-
|
222
|
-
### Runtime
|
223
|
-
|
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
|
-

|
227
|
-
|
228
|
-
## Test suite
|
95
|
+
The report of the execution should be:
|
229
96
|
|
230
|
-
|
97
|
+
> example/string_hello_world_spec.rb:19
|
98
|
+
> Success: expected to eq "Hello, Alice!".
|
99
|
+
> example/string_hello_world_spec.rb:25
|
100
|
+
> Success: expected to eq "Hello, Bob!".
|
231
101
|
|
232
|
-
##
|
102
|
+
## External links
|
233
103
|
|
234
|
-
*
|
235
|
-
*
|
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
|
-
* Twitter: [https://twitter.com/cyri\_](https://twitter.com/cyri\_)
|
239
|
-
|
240
|
-
## Special thanks ❤️
|
241
|
-
|
242
|
-
I would like to thank the whole [RSpec team](https://rspec.info/about/) for all their work.
|
243
|
-
It's a great framework and it's a pleasure to work with every day.
|
244
|
-
|
245
|
-
Without RSpec, this clone would not have been possible.
|
246
|
-
|
247
|
-
## Buy me a coffee ☕
|
248
|
-
|
249
|
-
If you like this project please consider making a small donation.
|
250
|
-
|
251
|
-
[](https://etherscan.io/address/0x834b5c1feaff5aebf9cd0f25dc38e741d65ab773)
|
104
|
+
* [Official RSpec project](https://rspec.info/)
|
105
|
+
* [Personal RSpec reimplementation](https://r-spec.dev/)
|
252
106
|
|
253
107
|
## Versioning
|
254
108
|
|
255
|
-
|
109
|
+
__RSpec__ uses [Semantic Versioning 2.0.0](https://semver.org/)
|
256
110
|
|
257
111
|
## License
|
258
112
|
|
259
113
|
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
|
-

|
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.2
|
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:
|
@@ -232,14 +174,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
232
174
|
requirements:
|
233
175
|
- - ">="
|
234
176
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
177
|
+
version: 3.0.4
|
236
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
179
|
requirements:
|
238
|
-
- - "
|
180
|
+
- - ">="
|
239
181
|
- !ruby/object:Gem::Version
|
240
|
-
version:
|
182
|
+
version: '0'
|
241
183
|
requirements: []
|
242
|
-
rubygems_version: 3.
|
184
|
+
rubygems_version: 3.2.33
|
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
|