rspec-expectations 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd7955a9011398c45ea3e013003f609e10a45d3
4
- data.tar.gz: ef807b08b3196f44fbdb0713c932e9a4fa55b5e4
3
+ metadata.gz: 55fe7e69aa2f95c64cc33b1805bbd01569c0c269
4
+ data.tar.gz: 1315e9e9bb890c7088a2ba123fe0ad8af077f2a8
5
5
  SHA512:
6
- metadata.gz: 748b7325cf0703054bb349274b192f958f1a4e86d42089ea1583eb93180ae4a22be0c90ed19e578d5dee32ec241c12a932e262df09b74c426a4295495433d21c
7
- data.tar.gz: d108d4262782769604c8d343dfa0b5aefe0f119237ca820422b836b45ccbe846e872c71f34324e733fd09ca398b1268945d2a680fa0e6aae7e976491aa9ec8dc
6
+ metadata.gz: 20496ddf5da00c886e02c27353860d953803fe33d76603955c8398758a8f86d05e3a3245e460fca389dd82ba012ee609f8d7b2cf92166b4568e17ab98f4d769e
7
+ data.tar.gz: 75767f0423ca2911f4161091aac4bc5b66e8b9deb01eb9490e00da0277ee036ab06be3d1f9f63930394fc46c426818227852f2f90a04c98288e7d69ca2ecad95
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ��ͅnUE�%Y�������>����bf�9O� 34��$Mަl���-'�_ ���?]��ߞ��q2��ν��l?N��O)�H{G}N��v�^�4rvE��+�gb��h}*1v�3��ӷ�*J����>�D/x[��1Ŀ����4 ��w���X.J��Y����e6[��oQ���<�~Sbt��✃͹,�4���m��ح�0x��&�&k>�
2
- ��0����O{���yv�w}ۯ�
1
+ O/Cs����jt��V��l��鋫���'Rz��0��BYQ��a5���fѻNGnB�����fվ~4�h��ălg
@@ -1,3 +1,14 @@
1
+ ### 3.1.2 / 2014-09-26
2
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.1.1...v3.1.2)
3
+
4
+ Bug Fixes:
5
+
6
+ * Fix `define_negated_matcher` so that matchers that support fluent
7
+ interfaces continue to be negated after you use the chained method.
8
+ (Myron Marston, #656)
9
+ * Fix `define_negated_matcher` so that the matchers fail with an
10
+ appropriate failure message. (Myron Marston, #659)
11
+
1
12
  ### 3.1.1 / 2014-09-15
2
13
  [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.1.0...v3.1.1)
3
14
 
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.1.1'
5
+ STRING = '3.1.2'
6
6
  end
7
7
  end
8
8
  end
@@ -23,8 +23,8 @@ module RSpec
23
23
  # used.
24
24
  def method_missing(*)
25
25
  return_val = super
26
- return return_val unless return_val.respond_to?(:description)
27
- AliasedMatcher.new(return_val, @description_block)
26
+ return return_val unless RSpec::Matchers.is_a_matcher?(return_val)
27
+ self.class.new(return_val, @description_block)
28
28
  end
29
29
 
30
30
  # Provides the description of the aliased matcher. Aliased matchers
@@ -80,6 +80,37 @@ module RSpec
80
80
  def does_not_match?(*args, &block)
81
81
  @base_matcher.matches?(*args, &block)
82
82
  end
83
+
84
+ def failure_message
85
+ optimal_failure_message(__method__, :failure_message_when_negated)
86
+ end
87
+
88
+ def failure_message_when_negated
89
+ optimal_failure_message(__method__, :failure_message)
90
+ end
91
+
92
+ private
93
+
94
+ DefaultFailureMessages = BuiltIn::BaseMatcher::DefaultFailureMessages
95
+
96
+ # For a matcher that uses the default failure messages, we prefer to
97
+ # use the override provided by the `description_block`, because it
98
+ # includes the phrasing that the user has expressed a preference for
99
+ # by going through the effort of defining a negated matcher.
100
+ #
101
+ # However, if the override didn't actually change anything, then we
102
+ # should return the opposite failure message instead -- the overriden
103
+ # message is going to be confusing if we return it as-is, as it represents
104
+ # the non-negated failure message for a negated match (or vice versa).
105
+ def optimal_failure_message(same, inverted)
106
+ if DefaultFailureMessages.has_default_failure_messages?(@base_matcher)
107
+ base_message = @base_matcher.__send__(same)
108
+ overriden = @description_block.call(base_message)
109
+ return overriden if overriden != base_message
110
+ end
111
+
112
+ @base_matcher.__send__(inverted)
113
+ end
83
114
  end
84
115
  end
85
116
  end
@@ -52,26 +52,6 @@ module RSpec
52
52
  end
53
53
  end
54
54
 
55
- # @api private
56
- # Provides a good generic failure message. Based on `description`.
57
- # When subclassing, if you are not satisfied with this failure message
58
- # you often only need to override `description`.
59
- # @return [String]
60
- def failure_message
61
- assert_ivars :@actual
62
- "expected #{@actual.inspect} to #{description}"
63
- end
64
-
65
- # @api private
66
- # Provides a good generic negative failure message. Based on `description`.
67
- # When subclassing, if you are not satisfied with this failure message
68
- # you often only need to override `description`.
69
- # @return [String]
70
- def failure_message_when_negated
71
- assert_ivars :@actual
72
- "expected #{@actual.inspect} not to #{description}"
73
- end
74
-
75
55
  # @api private
76
56
  # Generates a "pretty" description using the logic in {Pretty}.
77
57
  # @return [String]
@@ -114,6 +94,38 @@ module RSpec
114
94
  else
115
95
  alias present_ivars instance_variables
116
96
  end
97
+
98
+ # @api private
99
+ # Provides default implementations of failure messages, based on the `description`.
100
+ module DefaultFailureMessages
101
+ # @api private
102
+ # Provides a good generic failure message. Based on `description`.
103
+ # When subclassing, if you are not satisfied with this failure message
104
+ # you often only need to override `description`.
105
+ # @return [String]
106
+ def failure_message
107
+ "expected #{actual.inspect} to #{description}"
108
+ end
109
+
110
+ # @api private
111
+ # Provides a good generic negative failure message. Based on `description`.
112
+ # When subclassing, if you are not satisfied with this failure message
113
+ # you often only need to override `description`.
114
+ # @return [String]
115
+ def failure_message_when_negated
116
+ "expected #{actual.inspect} not to #{description}"
117
+ end
118
+
119
+ # @private
120
+ def self.has_default_failure_messages?(matcher)
121
+ matcher.method(:failure_message).owner == self &&
122
+ matcher.method(:failure_message_when_negated).owner == self
123
+ rescue NameError
124
+ false
125
+ end
126
+ end
127
+
128
+ include DefaultFailureMessages
117
129
  end
118
130
  end
119
131
  end
@@ -245,6 +245,8 @@ module RSpec
245
245
  # override any of these using the {RSpec::Matchers::DSL::Macros Macros} methods
246
246
  # from within an `RSpec::Matchers.define` block.
247
247
  module DefaultImplementations
248
+ include BuiltIn::BaseMatcher::DefaultFailureMessages
249
+
248
250
  # @api private
249
251
  # Used internally by objects returns by `should` and `should_not`.
250
252
  def diffable?
@@ -256,16 +258,6 @@ module RSpec
256
258
  "#{name_to_sentence}#{to_sentence expected}#{chained_method_clause_sentences}"
257
259
  end
258
260
 
259
- # The default failure message for positive expectations.
260
- def failure_message
261
- "expected #{actual.inspect} to #{description}"
262
- end
263
-
264
- # The default failure message for negative expectations.
265
- def failure_message_when_negated
266
- "expected #{actual.inspect} not to #{description}"
267
- end
268
-
269
261
  # Matchers do not support block expectations by default. You
270
262
  # must opt-in.
271
263
  def supports_block_expectations?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -33,7 +33,7 @@ cert_chain:
33
33
  1yHC1AcSYpvi2dAbOiHT5iQF+krm4wse8KctXgTNnjMsHEoGKulJS2/sZl90jcCz
34
34
  muA=
35
35
  -----END CERTIFICATE-----
36
- date: 2014-09-15 00:00:00.000000000 Z
36
+ date: 2014-09-26 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec-support
@@ -205,6 +205,6 @@ rubyforge_project: rspec
205
205
  rubygems_version: 2.2.2
206
206
  signing_key:
207
207
  specification_version: 4
208
- summary: rspec-expectations-3.1.1
208
+ summary: rspec-expectations-3.1.2
209
209
  test_files: []
210
210
  has_rdoc:
metadata.gz.sig CHANGED
Binary file