rspec-expectations 3.8.5 → 3.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ RSpec::Support.require_rspec_support "with_keywords_when_needed"
2
+
1
3
  module RSpec
2
4
  module Matchers
3
5
  # Defines the custom matcher DSL.
@@ -147,8 +149,14 @@ module RSpec
147
149
  # is rarely necessary, but can be helpful, for example, when specifying
148
150
  # asynchronous processes that require different timeouts.
149
151
  #
152
+ # By default the match block will swallow expectation errors (e.g.
153
+ # caused by using an expectation such as `expect(1).to eq 2`), if you
154
+ # with to allow these to bubble up, pass in the option
155
+ # `:notify_expectation_failures => true`.
156
+ #
157
+ # @param [Hash] options for defining the behavior of the match block.
150
158
  # @yield [Object] actual the actual value (i.e. the value wrapped by `expect`)
151
- def match_when_negated(&match_block)
159
+ def match_when_negated(options={}, &match_block)
152
160
  define_user_override(:does_not_match?, match_block) do |actual|
153
161
  begin
154
162
  @actual = actual
@@ -156,6 +164,7 @@ module RSpec
156
164
  super(*actual_arg_for(match_block))
157
165
  end
158
166
  rescue RSpec::Expectations::ExpectationNotMetError
167
+ raise if options[:notify_expectation_failures]
159
168
  false
160
169
  end
161
170
  end
@@ -394,10 +403,6 @@ module RSpec
394
403
  false
395
404
  end
396
405
 
397
- def supports_value_expectations?
398
- true
399
- end
400
-
401
406
  # Most matchers do not expect call stack jumps.
402
407
  def expects_call_stack_jump?
403
408
  false
@@ -457,11 +462,12 @@ module RSpec
457
462
  @chained_method_clauses = []
458
463
  @block_arg = block_arg
459
464
 
460
- class << self
465
+ klass = class << self
461
466
  # See `Macros#define_user_override` above, for an explanation.
462
467
  include(@user_method_defs = Module.new)
463
468
  self
464
- end.class_exec(*expected, &declarations)
469
+ end
470
+ RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *expected, &declarations)
465
471
  end
466
472
 
467
473
  # Provides the expected value. This will return an array if
@@ -525,6 +531,9 @@ module RSpec
525
531
  super(method, *args, &block)
526
532
  end
527
533
  end
534
+ # The method_missing method should be refactored to pass kw args in RSpec 4
535
+ # then this can be removed
536
+ ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
528
537
  end
529
538
  end
530
539
  end
@@ -24,7 +24,7 @@ module RSpec
24
24
  # list([]) #=> ""
25
25
  #
26
26
  def self.list(obj)
27
- return " #{RSpec::Support::ObjectFormatter.format(obj)}" if !obj || Struct === obj
27
+ return " #{RSpec::Support::ObjectFormatter.format(obj)}" if !obj || Struct === obj || Hash === obj
28
28
  items = Array(obj).map { |w| RSpec::Support::ObjectFormatter.format(w) }
29
29
  case items.length
30
30
  when 0
@@ -52,20 +52,29 @@ module RSpec
52
52
 
53
53
  private
54
54
 
55
- def self.diff_label_for(matcher)
56
- "Diff for (#{truncated(RSpec::Support::ObjectFormatter.format(matcher))}):"
57
- end
55
+ class << self
56
+ private
57
+
58
+ def diff_label_for(matcher)
59
+ "Diff for (#{truncated(RSpec::Support::ObjectFormatter.format(matcher))}):"
60
+ end
58
61
 
59
- def self.truncated(description)
60
- return description if description.length <= DESCRIPTION_MAX_LENGTH
61
- description[0...DESCRIPTION_MAX_LENGTH - 3] << "..."
62
+ def truncated(description)
63
+ return description if description.length <= DESCRIPTION_MAX_LENGTH
64
+ description[0...DESCRIPTION_MAX_LENGTH - 3] << "..."
65
+ end
62
66
  end
63
67
 
64
68
  def diffs(differ, actual)
65
69
  @expected_list.map do |(expected, diff_label)|
66
70
  diff = differ.diff(actual, expected)
67
71
  next if diff.strip.empty?
68
- "#{diff_label}#{diff}"
72
+ if diff == "\e[0m\n\e[0m"
73
+ "#{diff_label}\n" \
74
+ " <The diff is empty, are your objects producing identical `#inspect` output?>"
75
+ else
76
+ "#{diff_label}#{diff}"
77
+ end
69
78
  end.compact.join("\n")
70
79
  end
71
80
  end
@@ -60,12 +60,6 @@ module RSpec
60
60
  # @return [Boolean] true if this matcher can be used in block expressions.
61
61
  # @note If not defined, RSpec assumes a value of `false` for this method.
62
62
 
63
- # @!method supports_value_expectations?
64
- # Indicates that this matcher can be used in a value expectation expression,
65
- # such as `expect(foo).to eq(bar)`.
66
- # @return [Boolean] true if this matcher can be used in value expressions.
67
- # @note If not defined, RSpec assumes a value of `true` for this method.
68
-
69
63
  # @!method expects_call_stack_jump?
70
64
  # Indicates that when this matcher is used in a block expectation
71
65
  # expression, it expects the block to use a ruby construct that causes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.5
4
+ version: 3.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
8
8
  - David Chelimsky
9
9
  - Myron Marston
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain:
13
13
  - |
@@ -45,7 +45,7 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2019-10-02 00:00:00.000000000 Z
48
+ date: 2020-10-23 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
@@ -53,14 +53,14 @@ dependencies:
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.8.0
56
+ version: 3.9.0
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 3.8.0
63
+ version: 3.9.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,20 @@ dependencies:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '5.2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">"
131
+ - !ruby/object:Gem::Version
132
+ version: 10.0.0
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">"
138
+ - !ruby/object:Gem::Version
139
+ version: 10.0.0
126
140
  description: rspec-expectations provides a simple, readable API to express expected
127
141
  outcomes of a code example.
128
142
  email: rspec@googlegroups.com
@@ -188,11 +202,11 @@ licenses:
188
202
  - MIT
189
203
  metadata:
190
204
  bug_tracker_uri: https://github.com/rspec/rspec-expectations/issues
191
- changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.8.5/Changelog.md
205
+ changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.9.3/Changelog.md
192
206
  documentation_uri: https://rspec.info/documentation/
193
207
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
194
208
  source_code_uri: https://github.com/rspec/rspec-expectations
195
- post_install_message:
209
+ post_install_message:
196
210
  rdoc_options:
197
211
  - "--charset=UTF-8"
198
212
  require_paths:
@@ -208,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
222
  - !ruby/object:Gem::Version
209
223
  version: '0'
210
224
  requirements: []
211
- rubygems_version: 3.0.6
212
- signing_key:
225
+ rubygems_version: 3.1.3
226
+ signing_key:
213
227
  specification_version: 4
214
- summary: rspec-expectations-3.8.5
228
+ summary: rspec-expectations-3.9.3
215
229
  test_files: []
metadata.gz.sig CHANGED
Binary file