Hello community,
here is the log from the commit of package rubygem-rspec-mocks for
openSUSE:Factory checked in at 2016-07-16 22:11:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-rspec-mocks (Old)
and /work/SRC/openSUSE:Factory/.rubygem-rspec-mocks.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-rspec-mocks"
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-rspec-mocks/rubygem-rspec-mocks.changes
2016-01-28 17:19:56.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.rubygem-rspec-mocks.new/rubygem-rspec-mocks.changes
2016-07-16 22:11:18.000000000 +0200
@@ -1,0 +2,58 @@
+Sat Jul 2 05:26:34 UTC 2016 - [email protected]
+
+- updated to version 3.5.0
+ see installed Changelog.md
+
+ ### 3.5.0 / 2016-07-01
+ [Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta4...v3.5.0)
+
+ Enhancements:
+
+ * Provides a nice string representation of
+ `RSpec::Mocks::MessageExpectation` (Myron Marston, #1095)
+
+ ### 3.5.0.beta4 / 2016-06-05
+ [Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta3...v3.5.0.beta4)
+
+ Enhancements:
+
+ * Add `and_throw` to any instance handling. (Tobias Bühlmann, #1068)
+
+ ### 3.5.0.beta3 / 2016-04-02
+ [Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta2...v3.5.0.beta3)
+
+ Enhancements:
+
+ * Issue warning when attempting to use unsupported
+ `allow(...).to receive(...).ordered`. (Jon Rowe, #1000)
+ * Add `rspec/mocks/minitest_integration`, to properly integrate rspec-mocks
+ with minitest. (Myron Marston, #1065)
+
+ ### 3.5.0.beta2 / 2016-03-10
+ [Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta1...v3.5.0.beta2)
+
+ Enhancements:
+
+ * Improve error message displayed when using `and_wrap_original` on pure test
+ doubles. (betesh, #1063)
+
+ Bug Fixes:
+
+ * Fix issue that prevented `receive_message_chain(...).with(...)` working
+ correctly on "any instance" mocks. (Jon Rowe, #1061)
+
+ ### 3.5.0.beta1 / 2016-02-06
+ [Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.4.1...v3.5.0.beta1)
+
+ Bug Fixes:
+
+ * Allow `any_instance_of(...).to receive(...)` to use `and_yield` multiple
+ times. (Kilian Cirera Sant, #1054)
+ * Allow matchers which inherit from `rspec-mocks` matchers to be used for
+ `allow`. (Andrew Kozin, #1056)
+ * Prevent stubbing `respond_to?` on partial doubles from causing infinite
+ recursion. (Jon Rowe, #1013)
+ * Prevent aliased methods from disapearing after being mocked with
+ `any_instance` (regression from #1043). (Joe Rafaniello, #1060)
+
+-------------------------------------------------------------------
Old:
----
rspec-mocks-3.4.1.gem
New:
----
rspec-mocks-3.5.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-rspec-mocks.spec ++++++
--- /var/tmp/diff_new_pack.0dxM96/_old 2016-07-16 22:11:19.000000000 +0200
+++ /var/tmp/diff_new_pack.0dxM96/_new 2016-07-16 22:11:19.000000000 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-rspec-mocks
-Version: 3.4.1
+Version: 3.5.0
Release: 0
%define mod_name rspec-mocks
%define mod_full_name %{mod_name}-%{version}
@@ -33,7 +33,7 @@
BuildRequires: %{rubygem gem2rpm}
BuildRequires: %{rubygem rdoc > 3.10}
BuildRequires: ruby-macros >= 5
-Url: http://github.com/rspec/rspec-mocks
+Url: https://github.com/rspec/rspec-mocks
Source: http://rubygems.org/gems/%{mod_full_name}.gem
Source1: gem2rpm.yml
Summary: RSpec's 'test double' framework, with support for stubbing and
mocking
++++++ rspec-mocks-3.4.1.gem -> rspec-mocks-3.5.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Changelog.md new/Changelog.md
--- old/Changelog.md 2016-01-11 00:57:10.000000000 +0100
+++ new/Changelog.md 2016-07-01 17:46:30.000000000 +0200
@@ -1,3 +1,55 @@
+### 3.5.0 / 2016-07-01
+[Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta4...v3.5.0)
+
+Enhancements:
+
+* Provides a nice string representation of
+ `RSpec::Mocks::MessageExpectation` (Myron Marston, #1095)
+
+### 3.5.0.beta4 / 2016-06-05
+[Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta3...v3.5.0.beta4)
+
+Enhancements:
+
+* Add `and_throw` to any instance handling. (Tobias Bühlmann, #1068)
+
+### 3.5.0.beta3 / 2016-04-02
+[Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta2...v3.5.0.beta3)
+
+Enhancements:
+
+* Issue warning when attempting to use unsupported
+ `allow(...).to receive(...).ordered`. (Jon Rowe, #1000)
+* Add `rspec/mocks/minitest_integration`, to properly integrate rspec-mocks
+ with minitest. (Myron Marston, #1065)
+
+### 3.5.0.beta2 / 2016-03-10
+[Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta1...v3.5.0.beta2)
+
+Enhancements:
+
+* Improve error message displayed when using `and_wrap_original` on pure test
+ doubles. (betesh, #1063)
+
+Bug Fixes:
+
+* Fix issue that prevented `receive_message_chain(...).with(...)` working
+ correctly on "any instance" mocks. (Jon Rowe, #1061)
+
+### 3.5.0.beta1 / 2016-02-06
+[Full
Changelog](http://github.com/rspec/rspec-mocks/compare/v3.4.1...v3.5.0.beta1)
+
+Bug Fixes:
+
+* Allow `any_instance_of(...).to receive(...)` to use `and_yield` multiple
+ times. (Kilian Cirera Sant, #1054)
+* Allow matchers which inherit from `rspec-mocks` matchers to be used for
+ `allow`. (Andrew Kozin, #1056)
+* Prevent stubbing `respond_to?` on partial doubles from causing infinite
+ recursion. (Jon Rowe, #1013)
+* Prevent aliased methods from disapearing after being mocked with
+ `any_instance` (regression from #1043). (Joe Rafaniello, #1060)
+
### 3.4.1 / 2016-01-10
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.4.0...v3.4.1)
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
Files old/checksums.yaml.gz.sig and new/checksums.yaml.gz.sig differ
Files old/data.tar.gz.sig and new/data.tar.gz.sig differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/any_instance/recorder.rb
new/lib/rspec/mocks/any_instance/recorder.rb
--- old/lib/rspec/mocks/any_instance/recorder.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/any_instance/recorder.rb 2016-07-01
17:46:30.000000000 +0200
@@ -193,7 +193,28 @@
alias_method_name = build_alias_method_name(method_name)
@klass.class_exec(@backed_up_method_owner) do
|backed_up_method_owner|
remove_method method_name
- alias_method method_name, alias_method_name if
backed_up_method_owner[method_name.to_sym] == self
+
+ # A @klass can have methods implemented (see Method#owner) in
@klass
+ # or inherited from a superclass. In ruby 2.2 and earlier, we can
copy
+ # a method regardless of the 'owner' and restore it to @klass after
+ # because a call to 'super' from @klass's copied method would end
up
+ # calling the original class's superclass's method.
+ #
+ # With the commit below, available starting in 2.3.0, ruby changed
+ # this behavior and a call to 'super' from the method copied to
@klass
+ # will call @klass's superclass method, which is the original
+ # implementer of this method! This leads to very strange errors
+ # if @klass's copied method calls 'super', since it would end up
+ # calling itself, the original method implemented in @klass's
+ # superclass.
+ #
+ # For ruby 2.3 and above, we need to only restore methods that
+ # @klass originally owned.
+ #
+ #
https://github.com/ruby/ruby/commit/c8854d2ca4be9ee6946e6d17b0e17d9ef130ee81
+ if RUBY_VERSION < "2.3" ||
backed_up_method_owner[method_name.to_sym] == self
+ alias_method method_name, alias_method_name
+ end
remove_method alias_method_name
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/any_instance/stub_chain.rb
new/lib/rspec/mocks/any_instance/stub_chain.rb
--- old/lib/rspec/mocks/any_instance/stub_chain.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/any_instance/stub_chain.rb 2016-07-01
17:46:30.000000000 +0200
@@ -30,7 +30,8 @@
:with => [nil],
:and_return => [:with, nil],
:and_raise => [:with, nil],
- :and_yield => [:with, nil],
+ :and_yield => [:with, :and_yield, nil],
+ :and_throw => [:with, nil],
:and_call_original => [:with, nil],
:and_wrap_original => [:with, nil]
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/any_instance/stub_chain_chain.rb
new/lib/rspec/mocks/any_instance/stub_chain_chain.rb
--- old/lib/rspec/mocks/any_instance/stub_chain_chain.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/any_instance/stub_chain_chain.rb 2016-07-01
17:46:30.000000000 +0200
@@ -16,6 +16,7 @@
def invocation_order
@invocation_order ||= {
+ :with => [nil],
:and_return => [nil],
:and_raise => [nil],
:and_yield => [nil]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/error_generator.rb
new/lib/rspec/mocks/error_generator.rb
--- old/lib/rspec/mocks/error_generator.rb 2016-01-11 00:57:10.000000000
+0100
+++ new/lib/rspec/mocks/error_generator.rb 2016-07-01 17:46:30.000000000
+0200
@@ -214,8 +214,35 @@
def expectation_on_nil_message(method_name)
"An expectation of `:#{method_name}` was set on `nil`. " \
- "To allow expectations on `nil` and suppress this message, set
`config.allow_expectations_on_nil` to `true`. " \
- "To disallow expectations on `nil`, set
`config.allow_expectations_on_nil` to `false`"
+ "To allow expectations on `nil` and suppress this message, set
`config.allow_message_expectations_on_nil` to `true`. " \
+ "To disallow expectations on `nil`, set
`config.allow_message_expectations_on_nil` to `false`"
+ end
+
+ # @private
+ def intro(unwrapped=false)
+ case @target
+ when TestDouble then TestDoubleFormatter.format(@target, unwrapped)
+ when Class then
+ formatted = "#{@target.inspect} (class)"
+ return formatted if unwrapped
+ "#<#{formatted}>"
+ when NilClass then "nil"
+ else @target.inspect
+ end
+ end
+
+ # @private
+ def method_call_args_description(args, generic_prefix=" with arguments:
", matcher_prefix=" with ")
+ case args.first
+ when ArgumentMatchers::AnyArgsMatcher then "#{matcher_prefix}any
arguments"
+ when ArgumentMatchers::NoArgsMatcher then "#{matcher_prefix}no
arguments"
+ else
+ if yield
+ "#{generic_prefix}#{format_args(args)}"
+ else
+ ""
+ end
+ end
end
private
@@ -234,19 +261,6 @@
end
end
- def method_call_args_description(args)
- case args.first
- when ArgumentMatchers::AnyArgsMatcher then " with any arguments"
- when ArgumentMatchers::NoArgsMatcher then " with no arguments"
- else
- if yield
- " with arguments: #{format_args(args)}"
- else
- ""
- end
- end
- end
-
def unexpected_arguments_message(expected_args_string,
actual_args_string)
"with unexpected arguments\n expected: #{expected_args_string}\n
got: #{actual_args_string}"
end
@@ -290,18 +304,6 @@
RSpec::Support::Differ.new(:color => RSpec::Mocks.configuration.color?)
end
- def intro(unwrapped=false)
- case @target
- when TestDouble then TestDoubleFormatter.format(@target, unwrapped)
- when Class then
- formatted = "#{@target.inspect} (class)"
- return formatted if unwrapped
- "#<#{formatted}>"
- when NilClass then "nil"
- else @target
- end
- end
-
def __raise(message, backtrace_line=nil, source_id=nil)
message = opts[:message] unless opts[:message].nil?
exception = RSpec::Mocks::MockExpectationError.new(message)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/matchers/have_received.rb
new/lib/rspec/mocks/matchers/have_received.rb
--- old/lib/rspec/mocks/matchers/have_received.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/matchers/have_received.rb 2016-07-01
17:46:30.000000000 +0200
@@ -3,6 +3,8 @@
module Matchers
# @private
class HaveReceived
+ include Matcher
+
COUNT_CONSTRAINTS = %w[exactly at_least at_most times once twice
thrice]
ARGS_CONSTRAINTS = %w[with]
CONSTRAINTS = COUNT_CONSTRAINTS + ARGS_CONSTRAINTS + %w[ordered]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/matchers/receive.rb
new/lib/rspec/mocks/matchers/receive.rb
--- old/lib/rspec/mocks/matchers/receive.rb 2016-01-11 00:57:10.000000000
+0100
+++ new/lib/rspec/mocks/matchers/receive.rb 2016-07-01 17:46:30.000000000
+0200
@@ -5,6 +5,8 @@
module Matchers
# @private
class Receive
+ include Matcher
+
def initialize(message, block)
@message = message
@block = block
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/matchers/receive_message_chain.rb
new/lib/rspec/mocks/matchers/receive_message_chain.rb
--- old/lib/rspec/mocks/matchers/receive_message_chain.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/matchers/receive_message_chain.rb 2016-07-01
17:46:30.000000000 +0200
@@ -5,6 +5,8 @@
module Matchers
# @private
class ReceiveMessageChain
+ include Matcher
+
def initialize(chain, &block)
@chain = chain
@block = block
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/matchers/receive_messages.rb
new/lib/rspec/mocks/matchers/receive_messages.rb
--- old/lib/rspec/mocks/matchers/receive_messages.rb 2016-01-11
00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/matchers/receive_messages.rb 2016-07-01
17:46:30.000000000 +0200
@@ -3,6 +3,8 @@
module Matchers
# @private
class ReceiveMessages
+ include Matcher
+
def initialize(message_return_value_hash)
@message_return_value_hash = message_return_value_hash
@backtrace_line = CallerFilter.first_non_rspec_line
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/message_expectation.rb
new/lib/rspec/mocks/message_expectation.rb
--- old/lib/rspec/mocks/message_expectation.rb 2016-01-11 00:57:10.000000000
+0100
+++ new/lib/rspec/mocks/message_expectation.rb 2016-07-01 17:46:30.000000000
+0200
@@ -95,7 +95,7 @@
# counter.increment
# expect(counter.count).to eq(original_count + 1)
def and_call_original
- and_wrap_original do |original, *args, &block|
+ wrap_original(__method__) do |original, *args, &block|
original.call(*args, &block)
end
end
@@ -113,15 +113,7 @@
# original_method.call(*args, &block).first(10)
# end
def and_wrap_original(&block)
- if RSpec::Mocks::TestDouble === @method_double.object
-
@error_generator.raise_only_valid_on_a_partial_double(:and_call_original)
- else
- warn_about_stub_override if implementation.inner_action
- @implementation =
AndWrapOriginalImplementation.new(@method_double.original_implementation_callable,
block)
- @yield_receiver_to_implementation_block = false
- end
-
- nil
+ wrap_original(__method__, &block)
end
# @overload and_raise
@@ -336,6 +328,13 @@
# expect(api).to receive(:run).ordered
# expect(api).to receive(:finish).ordered
def ordered(&block)
+ if type == :stub
+ RSpec.warning(
+ "`allow(...).to receive(..).ordered` is not supported and will" \
+ "have no effect, use `and_return(*ordered_values)` instead."
+ )
+ end
+
self.inner_implementation_action = block
additional_expected_calls.times do
@order_group.register(self)
@@ -344,6 +343,14 @@
self
end
+ # @return [String] a nice representation of the message expectation
+ def to_s
+ args_description =
error_generator.method_call_args_description(@argument_list_matcher.expected_args,
"", "") { true }
+ args_description = "(#{args_description})" unless
args_description.start_with?("(")
+ "#<#{self.class}
#{error_generator.intro}.#{message}#{args_description}>"
+ end
+ alias inspect to_s
+
# @private
# Contains the parts of `MessageExpectation` that aren't part of
# rspec-mocks' public API. The class is very big and could really use
@@ -357,9 +364,13 @@
attr_writer :expected_received_count, :expected_from,
:argument_list_matcher
protected :expected_received_count=, :expected_from=,
:error_generator, :error_generator=, :implementation=
+ # @private
+ attr_reader :type
+
# rubocop:disable Style/ParameterLists
def initialize(error_generator, expectation_ordering, expected_from,
method_double,
type=:expectation, opts={}, &implementation_block)
+ @type = type
@error_generator = error_generator
@error_generator.opts = opts
@expected_from = expected_from
@@ -601,6 +612,18 @@
"Called from #{CallerFilter.first_non_rspec_line}."
)
end
+
+ def wrap_original(method_name, &block)
+ if RSpec::Mocks::TestDouble === @method_double.object
+ @error_generator.raise_only_valid_on_a_partial_double(method_name)
+ else
+ warn_about_stub_override if implementation.inner_action
+ @implementation =
AndWrapOriginalImplementation.new(@method_double.original_implementation_callable,
block)
+ @yield_receiver_to_implementation_block = false
+ end
+
+ nil
+ end
end
include ImplementationDetails
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/method_reference.rb
new/lib/rspec/mocks/method_reference.rb
--- old/lib/rspec/mocks/method_reference.rb 2016-01-11 00:57:10.000000000
+0100
+++ new/lib/rspec/mocks/method_reference.rb 2016-07-01 17:46:30.000000000
+0200
@@ -1,3 +1,5 @@
+RSpec::Support.require_rspec_support 'comparable_version'
+
module RSpec
module Mocks
# Represents a method on an object that may or may not be defined.
@@ -85,17 +87,25 @@
end
def self.method_visibility_for(object, method_name)
- instance_method_visibility_for(class << object; self; end,
method_name).tap do |vis|
- # If the method is not defined on the class,
`instance_method_visibility_for`
- # returns `nil`. However, it may be handled dynamically by
`method_missing`,
- # so here we check `respond_to` (passing false to not check private
methods).
- #
- # This only considers the public case, but I don't think it's
possible to
- # write `method_missing` in such a way that it handles a dynamic
message
- # with private or protected visibility. Ruby doesn't provide you with
- # the caller info.
- return :public if vis.nil? && object.respond_to?(method_name, false)
- end
+ vis = instance_method_visibility_for(class << object; self; end,
method_name)
+
+ # If the method is not defined on the class,
`instance_method_visibility_for`
+ # returns `nil`. However, it may be handled dynamically by
`method_missing`,
+ # so here we check `respond_to` (passing false to not check private
methods).
+ #
+ # This only considers the public case, but I don't think it's possible
to
+ # write `method_missing` in such a way that it handles a dynamic
message
+ # with private or protected visibility. Ruby doesn't provide you with
+ # the caller info.
+ return vis unless vis.nil?
+
+ proxy = RSpec::Mocks.space.proxy_for(object)
+ respond_to = proxy.method_double_if_exists_for_message(:respond_to?)
+
+ visible = respond_to && respond_to.original_method.call(method_name) ||
+ object.respond_to?(method_name)
+
+ return :public if visible
end
end
@@ -120,7 +130,7 @@
#
# This is necessary due to a bug in JRuby prior to 1.7.5 fixed in:
#
https://github.com/jruby/jruby/commit/99a0613fe29935150d76a9a1ee4cf2b4f63f4a27
- if RUBY_PLATFORM == 'java' && JRUBY_VERSION.split('.')[-1].to_i < 5
+ if RUBY_PLATFORM == 'java' &&
RSpec::Support::ComparableVersion.new(JRUBY_VERSION) < '1.7.5'
def find_method(mod)
mod.dup.instance_method(@method_name)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/minitest_integration.rb
new/lib/rspec/mocks/minitest_integration.rb
--- old/lib/rspec/mocks/minitest_integration.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/lib/rspec/mocks/minitest_integration.rb 2016-07-01 17:46:30.000000000
+0200
@@ -0,0 +1,68 @@
+require 'rspec/mocks'
+
+module RSpec
+ module Mocks
+ # @private
+ module MinitestIntegration
+ include ::RSpec::Mocks::ExampleMethods
+
+ def before_setup
+ ::RSpec::Mocks.setup
+ super
+ end
+
+ def after_teardown
+ super
+
+ # Only verify if there's not already an error. Otherwise
+ # we risk getting the same failure twice, since negative
+ # expectation violations raise both when the message is
+ # unexpectedly received, and also during `verify` (in case
+ # the first failure was caught by user code via a
+ # `rescue Exception`).
+ ::RSpec::Mocks.verify unless failures.any?
+ ensure
+ ::RSpec::Mocks.teardown
+ end
+ end
+ end
+end
+
+Minitest::Test.send(:include, RSpec::Mocks::MinitestIntegration)
+
+if defined?(::Minitest::Expectation)
+ if defined?(::RSpec::Expectations) &&
::Minitest::Expectation.method_defined?(:to)
+ # rspec/expectations/minitest_integration has already been loaded and
+ # has defined `to`/`not_to`/`to_not` on `Minitest::Expectation` so we do
+ # not want to here (or else we would interfere with rspec-expectations'
definition).
+ else
+ # ...otherwise, define those methods now. If
`rspec/expectations/minitest_integration`
+ # is loaded after this file, it'll overide the defintion here.
+ Minitest::Expectation.class_eval do
+ include RSpec::Mocks::ExpectationTargetMethods
+
+ def to(*args)
+ ctx.assertions += 1
+ super
+ end
+
+ def not_to(*args)
+ ctx.assertions += 1
+ super
+ end
+
+ def to_not(*args)
+ ctx.assertions += 1
+ super
+ end
+ end
+ end
+end
+
+module RSpec
+ module Mocks
+ remove_const :MockExpectationError
+ # Raised when a message expectation is not satisfied.
+ MockExpectationError = ::Minitest::Assertion
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/proxy.rb new/lib/rspec/mocks/proxy.rb
--- old/lib/rspec/mocks/proxy.rb 2016-01-11 00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/proxy.rb 2016-07-01 17:46:31.000000000 +0200
@@ -228,6 +228,11 @@
end
end
+ # @private
+ def method_double_if_exists_for_message(message)
+ method_double_for(message) if @method_doubles.key?(message.to_sym)
+ end
+
private
def method_double_for(message)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/targets.rb
new/lib/rspec/mocks/targets.rb
--- old/lib/rspec/mocks/targets.rb 2016-01-11 00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/targets.rb 2016-07-01 17:46:31.000000000 +0200
@@ -1,12 +1,8 @@
module RSpec
module Mocks
# @private
- class TargetBase
- def initialize(target)
- @target = target
- end
-
- def self.delegate_to(matcher_method)
+ module TargetDelegationClassMethods
+ def delegate_to(matcher_method)
define_method(:to) do |matcher, &block|
unless matcher_allowed?(matcher)
raise_unsupported_matcher(:to, matcher)
@@ -15,7 +11,7 @@
end
end
- def self.delegate_not_to(matcher_method, options={})
+ def delegate_not_to(matcher_method, options={})
method_name = options.fetch(:from)
define_method(method_name) do |matcher, &block|
case matcher
@@ -29,20 +25,25 @@
end
end
- def self.disallow_negation(method_name)
+ def disallow_negation(method_name)
define_method(method_name) do |matcher, *_args|
raise_negation_unsupported(method_name, matcher)
end
end
+ end
+
+ # @private
+ module TargetDelegationInstanceMethods
+ attr_reader :target
private
def matcher_allowed?(matcher)
- matcher.class.name.start_with?("RSpec::Mocks::Matchers".freeze)
+ Matchers::Matcher === matcher
end
def define_matcher(matcher, name, &block)
- matcher.__send__(name, @target, &block)
+ matcher.__send__(name, target, &block)
end
def raise_unsupported_matcher(method_name, matcher)
@@ -56,31 +57,54 @@
"`#{expression}(...).#{method_name} #{matcher.name}` is not
supported since it " \
"doesn't really make sense. What would it even mean?"
end
+ end
+
+ # @private
+ class TargetBase
+ def initialize(target)
+ @target = target
+ end
+
+ extend TargetDelegationClassMethods
+ include TargetDelegationInstanceMethods
+ end
+
+ # @private
+ module ExpectationTargetMethods
+ extend TargetDelegationClassMethods
+ include TargetDelegationInstanceMethods
+
+ delegate_to :setup_expectation
+ delegate_not_to :setup_negative_expectation, :from => :not_to
+ delegate_not_to :setup_negative_expectation, :from => :to_not
def expression
- self.class::EXPRESSION
+ :expect
end
end
# @private
+ class ExpectationTarget < TargetBase
+ include ExpectationTargetMethods
+ end
+
+ # @private
class AllowanceTarget < TargetBase
- EXPRESSION = :allow
+ def expression
+ :allow
+ end
+
delegate_to :setup_allowance
disallow_negation :not_to
disallow_negation :to_not
end
# @private
- class ExpectationTarget < TargetBase
- EXPRESSION = :expect
- delegate_to :setup_expectation
- delegate_not_to :setup_negative_expectation, :from => :not_to
- delegate_not_to :setup_negative_expectation, :from => :to_not
- end
-
- # @private
class AnyInstanceAllowanceTarget < TargetBase
- EXPRESSION = :allow_any_instance_of
+ def expression
+ :allow_any_instance_of
+ end
+
delegate_to :setup_any_instance_allowance
disallow_negation :not_to
disallow_negation :to_not
@@ -88,7 +112,10 @@
# @private
class AnyInstanceExpectationTarget < TargetBase
- EXPRESSION = :expect_any_instance_of
+ def expression
+ :expect_any_instance_of
+ end
+
delegate_to :setup_any_instance_expectation
delegate_not_to :setup_any_instance_negative_expectation, :from =>
:not_to
delegate_not_to :setup_any_instance_negative_expectation, :from =>
:to_not
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks/version.rb
new/lib/rspec/mocks/version.rb
--- old/lib/rspec/mocks/version.rb 2016-01-11 00:57:10.000000000 +0100
+++ new/lib/rspec/mocks/version.rb 2016-07-01 17:46:31.000000000 +0200
@@ -3,7 +3,7 @@
# Version information for RSpec mocks.
module Version
# Version of RSpec mocks currently in use in SemVer format.
- STRING = '3.4.1'
+ STRING = '3.5.0'
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rspec/mocks.rb new/lib/rspec/mocks.rb
--- old/lib/rspec/mocks.rb 2016-01-11 00:57:10.000000000 +0100
+++ new/lib/rspec/mocks.rb 2016-07-01 17:46:30.000000000 +0200
@@ -117,6 +117,10 @@
# Namespace for mock-related matchers.
module Matchers
+ # @private
+ # just a "tag" for rspec-mock matchers detection
+ module Matcher; end
+
autoload :HaveReceived, "rspec/mocks/matchers/have_received"
autoload :Receive, "rspec/mocks/matchers/receive"
autoload :ReceiveMessageChain,
"rspec/mocks/matchers/receive_message_chain"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2016-01-11 00:57:10.000000000 +0100
+++ new/metadata 2016-07-01 17:46:30.000000000 +0200
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: rspec-mocks
version: !ruby/object:Gem::Version
- version: 3.4.1
+ version: 3.5.0
platform: ruby
authors:
- Steven Baker
@@ -45,7 +45,7 @@
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
F3MdtaDehhjC
-----END CERTIFICATE-----
-date: 2016-01-10 00:00:00.000000000 Z
+date: 2016-07-01 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rspec-support
@@ -53,14 +53,14 @@
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: 3.4.0
+ version: 3.5.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: 3.4.0
+ version: 3.5.0
- !ruby/object:Gem::Dependency
name: diff-lcs
requirement: !ruby/object:Gem::Requirement
@@ -175,6 +175,7 @@
- lib/rspec/mocks/message_expectation.rb
- lib/rspec/mocks/method_double.rb
- lib/rspec/mocks/method_reference.rb
+- lib/rspec/mocks/minitest_integration.rb
- lib/rspec/mocks/mutate_const.rb
- lib/rspec/mocks/object_reference.rb
- lib/rspec/mocks/order_group.rb
@@ -188,7 +189,7 @@
- lib/rspec/mocks/verifying_message_expectation.rb
- lib/rspec/mocks/verifying_proxy.rb
- lib/rspec/mocks/version.rb
-homepage: http://github.com/rspec/rspec-mocks
+homepage: https://github.com/rspec/rspec-mocks
licenses:
- MIT
metadata: {}
@@ -209,9 +210,9 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.2.2
+rubygems_version: 2.5.1
signing_key:
specification_version: 4
-summary: rspec-mocks-3.4.1
+summary: rspec-mocks-3.5.0
test_files: []
has_rdoc:
Files old/metadata.gz.sig and new/metadata.gz.sig differ