rspec-expectations 3.5.0.beta4 → 3.5.0

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: 9d95b80f9a64a43b6e1f0e95dcc4e2dfd0cfa1af
4
- data.tar.gz: 7afd8be35cbcab028f3099e393c67dd762535b10
3
+ metadata.gz: 564420270880a852a9f86af59b32445beff85990
4
+ data.tar.gz: 68e50116cd97b1137f8ed688de17db436464b7b5
5
5
  SHA512:
6
- metadata.gz: 26f7c1f25f63e1af63acff047c324213d4c564c37e11f25210552ac3e5006026788b4ea74deeb8b84faf2e5faad4c92430c3b590437ae3f6e73d5ceefd54e6c7
7
- data.tar.gz: b6946ee2b2fd09495f45b08977a44c22b1a91721b54092f5a1a16c4210886a5df876d3fe1792f305dca932e7448831c8acf1890908c338690777766d36455c4a
6
+ metadata.gz: 18a464c2ffba3b59d6c998419b36462177b5246fd9a66cb73c693358b9985bdffeb6fd4cafc97beff928ced458cb4e70fd78731b2e35a2e7f0aca89d4b1a0e0e
7
+ data.tar.gz: b56c7c4cad9670fdf2925a700de34f1be6f14d2d197a12efba71f4f816e0a9a3f4f7c172c019b46ccab5344fe464362642ca53cbe522143fde63ad99d038978b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,7 @@
1
- ### 3.5 Development
2
- [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta4...master)
1
+ ### 3.5.0 / 2016-07-01
2
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta4...v3.5.0)
3
+
4
+ **No user facing changes since beta4**
3
5
 
4
6
  ### 3.5.0.beta4 / 2016-06-05
5
7
  [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta3...v3.5.0.beta4)
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.5.0.beta4'
5
+ STRING = '3.5.0'
6
6
  end
7
7
  end
8
8
  end
@@ -10,6 +10,9 @@ module RSpec
10
10
  def initialize(*names)
11
11
  @names = names
12
12
  @expected_arity = nil
13
+ @expected_keywords = []
14
+ @unlimited_arguments = nil
15
+ @arbitrary_keywords = nil
13
16
  end
14
17
 
15
18
  # @api public
@@ -22,6 +25,43 @@ module RSpec
22
25
  self
23
26
  end
24
27
 
28
+ # @api public
29
+ # Specifies keyword arguments, if any.
30
+ #
31
+ # @example
32
+ # expect(obj).to respond_to(:message).with_keywords(:color, :shape)
33
+ # @example with an expected number of arguments
34
+ # expect(obj).to respond_to(:message).with(3).arguments.and_keywords(:color, :shape)
35
+ def with_keywords(*keywords)
36
+ @expected_keywords = keywords
37
+ self
38
+ end
39
+ alias :and_keywords :with_keywords
40
+
41
+ # @api public
42
+ # Specifies that the method accepts any keyword, i.e. the method has
43
+ # a splatted keyword parameter of the form **kw_args.
44
+ #
45
+ # @example
46
+ # expect(obj).to respond_to(:message).with_any_keywords
47
+ def with_any_keywords
48
+ @arbitrary_keywords = true
49
+ self
50
+ end
51
+ alias :and_any_keywords :with_any_keywords
52
+
53
+ # @api public
54
+ # Specifies that the number of arguments has no upper limit, i.e. the
55
+ # method has a splatted parameter of the form *args.
56
+ #
57
+ # @example
58
+ # expect(obj).to respond_to(:message).with_unlimited_arguments
59
+ def with_unlimited_arguments
60
+ @unlimited_arguments = true
61
+ self
62
+ end
63
+ alias :and_unlimited_arguments :with_unlimited_arguments
64
+
25
65
  # @api public
26
66
  # No-op. Intended to be used as syntactic sugar when using `with`.
27
67
  #
@@ -70,15 +110,50 @@ module RSpec
70
110
  end
71
111
 
72
112
  def matches_arity?(actual, name)
73
- return true unless @expected_arity
113
+ expectation = Support::MethodSignatureExpectation.new
114
+
115
+ if @expected_arity.is_a?(Range)
116
+ expectation.min_count = @expected_arity.min
117
+ expectation.max_count = @expected_arity.max
118
+ else
119
+ expectation.min_count = @expected_arity
120
+ end
121
+
122
+ expectation.keywords = @expected_keywords
123
+ expectation.expect_unlimited_arguments = @unlimited_arguments
124
+ expectation.expect_arbitrary_keywords = @arbitrary_keywords
125
+
126
+ return true if expectation.empty?
74
127
 
75
128
  signature = Support::MethodSignature.new(Support.method_handle_for(actual, name))
76
- Support::StrictSignatureVerifier.new(signature, Array.new(@expected_arity)).valid?
129
+
130
+ Support::StrictSignatureVerifier.new(signature).with_expectation(expectation).valid?
77
131
  end
78
132
 
79
133
  def with_arity
80
- return "" unless @expected_arity
81
- " with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}"
134
+ str = ''
135
+ str << " with #{with_arity_string}" if @expected_arity
136
+ str << " #{str.length == 0 ? 'with' : 'and'} #{with_keywords_string}" if @expected_keywords && @expected_keywords.count > 0
137
+ str << " #{str.length == 0 ? 'with' : 'and'} unlimited arguments" if @unlimited_arguments
138
+ str << " #{str.length == 0 ? 'with' : 'and'} any keywords" if @arbitrary_keywords
139
+ str
140
+ end
141
+
142
+ def with_arity_string
143
+ "#{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}"
144
+ end
145
+
146
+ def with_keywords_string
147
+ kw_str = case @expected_keywords.count
148
+ when 1
149
+ @expected_keywords.first.inspect
150
+ when 2
151
+ @expected_keywords.map(&:inspect).join(' and ')
152
+ else
153
+ "#{@expected_keywords[0...-1].map(&:inspect).join(', ')}, and #{@expected_keywords.last.inspect}"
154
+ end
155
+
156
+ "keyword#{@expected_keywords.count == 1 ? '' : 's'} #{kw_str}"
82
157
  end
83
158
 
84
159
  def pp_names
@@ -37,6 +37,22 @@ module RSpec
37
37
  " #{items[0...-1].join(', ')}, and #{items[-1]}"
38
38
  end
39
39
  end
40
+
41
+ if RUBY_VERSION == '1.8.7'
42
+ # Not sure why, but on travis on 1.8.7 we have gotten these warnings:
43
+ # lib/rspec/matchers/english_phrasing.rb:28: warning: default `to_a' will be obsolete
44
+ # So it appears that `Array` can trigger that (e.g. by calling `to_a` on the passed object?)
45
+ # So here we replace `Kernel#Array` with our own warning-free implementation for 1.8.7.
46
+ # @private
47
+ # rubocop:disable Style/MethodName
48
+ def self.Array(obj)
49
+ case obj
50
+ when Array then obj
51
+ else [obj]
52
+ end
53
+ end
54
+ # rubocop:enable Style/MethodName
55
+ end
40
56
  end
41
57
  end
42
58
  end
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.5.0.beta4
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -45,22 +45,22 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2016-06-05 00:00:00.000000000 Z
48
+ date: 2016-07-01 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '='
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.5.0.beta4
56
+ version: 3.5.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.5.0.beta4
63
+ version: 3.5.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
212
  version: 1.8.7
213
213
  required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  requirements:
215
- - - ">"
215
+ - - ">="
216
216
  - !ruby/object:Gem::Version
217
- version: 1.3.1
217
+ version: '0'
218
218
  requirements: []
219
219
  rubyforge_project:
220
- rubygems_version: 2.2.2
220
+ rubygems_version: 2.5.1
221
221
  signing_key:
222
222
  specification_version: 4
223
- summary: rspec-expectations-3.5.0.beta4
223
+ summary: rspec-expectations-3.5.0
224
224
  test_files: []
225
225
  has_rdoc:
metadata.gz.sig CHANGED
Binary file