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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9467b45b9c26592854a9ce9ef7b9e5a549229a357602a3bf03241d5398f9cfcb
4
- data.tar.gz: 0b981cb23146042faa5e584400bd941012a9ab57f8d5f68a080add82d443e23c
3
+ metadata.gz: 8f36fea6becab89824a594297f3eb830f98277a412b304ba439f8c97cc2d84ff
4
+ data.tar.gz: c62d07b013183f8425a7775fb653f63958cb9a24c66ae5f84a34717df2c8e06d
5
5
  SHA512:
6
- metadata.gz: fef4a6f67cf9db940fcd906f6c3b3edf924c26577d2d504202776b1bcbaad35027f9071bd2658afae22d081800ae8997fe70ae73ca3b165726a7d2b630484975
7
- data.tar.gz: b55ed52e2842a7cf4b00ce01c8c2bf8c8fd91b53833dbf86498ead0febf55ed5cd86ab42b8c130e3a538ae5e0300df25c5beb114a778ae808cecf225d9198777
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
- Another (exprimental) attempt to get rid of `define_negated_matcher`. `dont` is not 100% grammatically
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
@@ -0,0 +1,13 @@
1
+ RSpec:
2
+ Language:
3
+ Includes:
4
+ Examples:
5
+ - its_block
6
+ - its_call
7
+ - its_map
8
+ - fits_block
9
+ - fits_call
10
+ - fits_map
11
+ - xits_block
12
+ - xits_call
13
+ - xits_map
@@ -3,7 +3,7 @@
3
3
  module Saharspec
4
4
  module Its
5
5
  module Block
6
- # Creates nested example which converts current subject to a block-subject.
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
- -> { subject }
39
+ subject
39
40
  end
40
41
 
41
42
  def is_expected
42
- expect(__call_subject)
43
+ expect { __call_subject }
43
44
  end
44
45
 
45
46
  example(nil, *options, &block)
@@ -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
- -> { subject.call(*args) }
34
+ subject.call(*args)
33
35
  end
34
36
 
35
37
  def is_expected
36
- expect(__call_subject)
38
+ expect { __call_subject }
37
39
  end
38
40
 
39
41
  example(nil, &block)
@@ -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 Style/MethodMissingSuper
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
@@ -3,6 +3,6 @@
3
3
  module Saharspec
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
- PATCH = 6
6
+ PATCH = 9
7
7
  VERSION = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
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.add_development_dependency 'rubocop', '~> 0.75'
29
- s.add_development_dependency 'rspec', '~> 3.7.0'
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.6
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: 2019-10-05 00:00:00.000000000 Z
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.75'
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.75'
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.0.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