saharspec 0.0.6 → 0.0.9
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/CHANGELOG.md +13 -0
- data/README.md +17 -7
- data/config/rubocop-rspec.yml +13 -0
- data/lib/saharspec/its/block.rb +4 -3
- data/lib/saharspec/its/call.rb +5 -3
- data/lib/saharspec/its/map.rb +1 -1
- data/lib/saharspec/matchers/dont.rb +8 -3
- data/lib/saharspec/version.rb +1 -1
- data/saharspec.gemspec +6 -2
- metadata +22 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f36fea6becab89824a594297f3eb830f98277a412b304ba439f8c97cc2d84ff
|
4
|
+
data.tar.gz: c62d07b013183f8425a7775fb653f63958cb9a24c66ae5f84a34717df2c8e06d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 216ee5c533e3e54e05ea03cdb12da2d582d7fa5d5dda82ac5ea9cb83eba22acb2f5eccf3257f644f224f79baa1e4879b6191de4c64d4aafd6be1fc67d58d2372
|
7
|
+
data.tar.gz: 2495db0a5cb29fcde39b6057f2789c0bcb70d71c53254f677ab8e8308abed99a8c2cd3bd70f8051fba29fed3e253e8537704f028ad4edf431ceafb41c8253b8c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Saharspec history
|
2
2
|
|
3
|
+
## 0.0.9 -- 2022-05-17
|
4
|
+
|
5
|
+
* Properly lint RSpec specs using `its_block`/`its_call`/`its_map` with `rubocop-rspec` >= 2.0 ([@ka8725](https://github.com/ka8725))
|
6
|
+
* Fix `its_block` and `its_call` to support RSpec 3.11
|
7
|
+
|
8
|
+
## 0.0.8 -- 2020-10-10
|
9
|
+
|
10
|
+
* Better `dont` failure message (just use underlying matchers `failure_message_when_negated`)
|
11
|
+
|
12
|
+
## 0.0.7 -- 2020-04-11
|
13
|
+
|
14
|
+
* Allow `its_call` to work properly with keyword args on Ruby 2.7
|
15
|
+
|
3
16
|
## 0.0.6 -- 2019-10-05
|
4
17
|
|
5
18
|
* Fix `dont.send_message` combination behavior (and generally, behavior of `dont.` with matchers
|
data/README.md
CHANGED
@@ -73,18 +73,18 @@ context 'when incompatible' do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# option 2. subject is block
|
76
|
-
subject { -> {2 + x } }
|
77
|
-
|
78
|
-
context 'when incompatible' do
|
79
|
-
let(:x) { '3' }
|
80
|
-
it { is_expected.to raise_error } # DRY
|
81
|
-
end
|
76
|
+
subject { -> { 2 + x } }
|
82
77
|
|
83
78
|
context 'when numeric' do
|
84
79
|
let(:x) { 3 }
|
85
80
|
it { expect(subject.call).to eq 5 } # not DRY
|
86
81
|
end
|
87
82
|
|
83
|
+
context 'when incompatible' do
|
84
|
+
let(:x) { '3' }
|
85
|
+
it { is_expected.to raise_error } # DRY
|
86
|
+
end
|
87
|
+
|
88
88
|
# after
|
89
89
|
require 'saharspec/matchers/ret'
|
90
90
|
|
@@ -157,7 +157,7 @@ require 'saharspec/matchers/eq_multiline'
|
|
157
157
|
|
158
158
|
### `dont`: matcher negation
|
159
159
|
|
160
|
-
|
160
|
+
Allows to get rid of gazilliions of `define_negated_matcher`. `dont` is not 100% grammatically
|
161
161
|
correct, yet short and readable enought. It just negates attached matcher.
|
162
162
|
|
163
163
|
```ruby
|
@@ -250,6 +250,16 @@ describe '#delete_at' do
|
|
250
250
|
end
|
251
251
|
```
|
252
252
|
|
253
|
+
### Linting with RuboCop RSpec
|
254
|
+
|
255
|
+
`rubocop-rspec` fails to properly detect RSpec constructs that Saharspec defines (`its_call`, `its_block`, `its_map`).
|
256
|
+
Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`:
|
257
|
+
|
258
|
+
```yaml
|
259
|
+
inherit_gem:
|
260
|
+
saharspec: config/rubocop-rspec.yml
|
261
|
+
```
|
262
|
+
|
253
263
|
## State & future
|
254
264
|
|
255
265
|
I use all of the components of the library on daily basis. Probably, I will extend it with other
|
data/lib/saharspec/its/block.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Saharspec
|
4
4
|
module Its
|
5
5
|
module Block
|
6
|
-
# Creates nested example
|
6
|
+
# Creates nested example that redefines implicit `is_expected` to use subject as a block.
|
7
7
|
#
|
8
8
|
# @example
|
9
9
|
#
|
@@ -34,12 +34,13 @@ module Saharspec
|
|
34
34
|
def its_block(*options, &block)
|
35
35
|
# rubocop:disable Lint/NestedMethodDefinition
|
36
36
|
describe('as block') do
|
37
|
+
# FIXME: Not necessary? (Previously, wrapped the subject in lambda, now just repeats it)
|
37
38
|
let(:__call_subject) do
|
38
|
-
|
39
|
+
subject
|
39
40
|
end
|
40
41
|
|
41
42
|
def is_expected
|
42
|
-
expect
|
43
|
+
expect { __call_subject }
|
43
44
|
end
|
44
45
|
|
45
46
|
example(nil, *options, &block)
|
data/lib/saharspec/its/call.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ruby2_keywords'
|
4
|
+
|
3
5
|
module Saharspec
|
4
6
|
module Its
|
5
7
|
module Call
|
@@ -25,15 +27,15 @@ module Saharspec
|
|
25
27
|
# its_call(5) { is_expected.to change(array, :length).by(1) }
|
26
28
|
# end
|
27
29
|
#
|
28
|
-
def its_call(*args, &block)
|
30
|
+
ruby2_keywords def its_call(*args, &block)
|
29
31
|
# rubocop:disable Lint/NestedMethodDefinition
|
30
32
|
describe("(#{args.map(&:inspect).join(', ')})") do
|
31
33
|
let(:__call_subject) do
|
32
|
-
|
34
|
+
subject.call(*args)
|
33
35
|
end
|
34
36
|
|
35
37
|
def is_expected
|
36
|
-
expect
|
38
|
+
expect { __call_subject }
|
37
39
|
end
|
38
40
|
|
39
41
|
example(nil, &block)
|
data/lib/saharspec/its/map.rb
CHANGED
@@ -32,7 +32,7 @@ module Saharspec
|
|
32
32
|
# @param block [Proc] The test itself. Inside it, `is_expected` (or `are_expected`) is related to result
|
33
33
|
# of `map`ping the subject.
|
34
34
|
#
|
35
|
-
def its_map(attribute, *options, &block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
35
|
+
def its_map(attribute, *options, &block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
36
36
|
# rubocop:disable Lint/NestedMethodDefinition
|
37
37
|
# TODO: better desciption for different cases
|
38
38
|
describe("map(&:#{attribute})") do
|
@@ -4,7 +4,8 @@ module Saharspec
|
|
4
4
|
module Matchers
|
5
5
|
# @private
|
6
6
|
class Not < RSpec::Matchers::BuiltIn::BaseMatcher
|
7
|
-
def initialize
|
7
|
+
def initialize(*)
|
8
|
+
super
|
8
9
|
@delegator = Delegator.new
|
9
10
|
end
|
10
11
|
|
@@ -27,11 +28,15 @@ module Saharspec
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
def failure_message
|
32
|
+
@matcher.failure_message_when_negated
|
33
|
+
end
|
34
|
+
|
30
35
|
def supports_block_expectations?
|
31
36
|
@matcher.supports_block_expectations?
|
32
37
|
end
|
33
38
|
|
34
|
-
def method_missing(m, *a, &b) # rubocop:disable
|
39
|
+
def method_missing(m, *a, &b) # rubocop:disable Lint/MissingSuper
|
35
40
|
if @matcher
|
36
41
|
@matcher.send(m, *a, &b)
|
37
42
|
else
|
@@ -41,7 +46,7 @@ module Saharspec
|
|
41
46
|
self
|
42
47
|
end
|
43
48
|
|
44
|
-
def respond_to_missing?(method, include_private = false)
|
49
|
+
def respond_to_missing?(method, include_private = false) # rubocop:disable Lint/MissingSuper
|
45
50
|
if @matcher
|
46
51
|
@matcher.respond_to?(method, include_private)
|
47
52
|
else
|
data/lib/saharspec/version.rb
CHANGED
data/saharspec.gemspec
CHANGED
@@ -25,8 +25,12 @@ Gem::Specification.new do |s|
|
|
25
25
|
|
26
26
|
s.required_ruby_version = '>= 2.3.0'
|
27
27
|
|
28
|
-
s.
|
29
|
-
|
28
|
+
s.add_runtime_dependency 'ruby2_keywords'
|
29
|
+
|
30
|
+
if RUBY_VERSION >= '2.4' # Newest Rubocop fails on 2.3
|
31
|
+
s.add_development_dependency 'rubocop', '~> 0.93'
|
32
|
+
end
|
33
|
+
s.add_development_dependency 'rspec', '>= 3.7.0'
|
30
34
|
s.add_development_dependency 'rspec-its'
|
31
35
|
s.add_development_dependency 'simplecov', '~> 0.9'
|
32
36
|
s.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,41 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saharspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Shepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby2_keywords
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubocop
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
33
|
+
version: '0.93'
|
20
34
|
type: :development
|
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: '0.
|
40
|
+
version: '0.93'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: 3.7.0
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: 3.7.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
@@ -119,6 +133,7 @@ files:
|
|
119
133
|
- CHANGELOG.md
|
120
134
|
- LICENSE.txt
|
121
135
|
- README.md
|
136
|
+
- config/rubocop-rspec.yml
|
122
137
|
- lib/saharspec.rb
|
123
138
|
- lib/saharspec/its.rb
|
124
139
|
- lib/saharspec/its/block.rb
|
@@ -153,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
168
|
- !ruby/object:Gem::Version
|
154
169
|
version: '0'
|
155
170
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.1.6
|
157
172
|
signing_key:
|
158
173
|
specification_version: 4
|
159
174
|
summary: Several additions for DRYer RSpec code
|