commit rubygem-mocha for openSUSE:Factory
Hello community, here is the log from the commit of package rubygem-mocha for openSUSE:Factory checked in at 2017-09-04 12:31:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-mocha (Old) and /work/SRC/openSUSE:Factory/.rubygem-mocha.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-mocha" Mon Sep 4 12:31:56 2017 rev:24 rq:519889 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-mocha/rubygem-mocha.changes 2016-11-07 12:23:03.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-mocha.new/rubygem-mocha.changes 2017-09-04 12:32:01.239804512 +0200 @@ -1,0 +2,25 @@ +Fri Aug 25 08:08:48 UTC 2017 - mschnitzer@suse.com + +- updated to version 1.3.0 + * Ensure all tests run individually - thanks to @chrisroos (#267) + * Update Travis CI build status badge to show master branch status (#264) + * Correct RSpec section of the README - thanks to @myronmarston (0cc039c8) + * Fix pretty printing of quotes in String#mocha_inspect (#215 & #223) + * Add release instructions to README - thanks to @chrisroos (70a5febd & 3c664df7) + * Require at least Ruby v1.8.7 in gemspec - thanks to @knappe (3e20be8e) + * Remove redundant InstanceMethod#method_exists? - thanks to @chrisroos (8f58eddf) + * Reduce risk of hitting bug 12832 in Ruby v2.3 - thanks to @chrisroos (#277 & eca7560c) + * Fix JRuby build - thanks to @headius (jruby/jruby#4250) & @chrisroos (#274) + * Add latest stable version of JRuby to Travis CI build matrix (#288) + * Fix Ruby v1.8.7 builds on Travis CI (928b5a40 & 460dce5b) + * Deprecate passing block to mock object constructor (#290) + * Add a known issue to README for Ruby bug 12876 (#276) + * Add Ruby 2.4 and ruby-head to Travis CI build matrix - thanks to @junaruga (#297) + * Fix Mocha::ParameterMatchers#includes for Array values - thanks to @timcraft (#302) + * Use faster container-based virtual environments for Travis CI builds (#305) + * Rename Mocha::ParameterMatchers::QueryStringMatches to QueryString (#306) + * Handle blank parameter value for query string matcher - thanks to @weynsee (#303 & #304) + * Rename Mocha::ParameterMatchers::QueryString -> EquivalentUri (#307) + * Use do ... end instead of { ... } in acceptance tests - thanks to @chrisroos (#294) + +------------------------------------------------------------------- Old: ---- mocha-1.2.1.gem New: ---- mocha-1.3.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-mocha.spec ++++++ --- /var/tmp/diff_new_pack.KwZU3W/_old 2017-09-04 12:32:01.947704981 +0200 +++ /var/tmp/diff_new_pack.KwZU3W/_new 2017-09-04 12:32:01.947704981 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-mocha # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,16 +24,16 @@ # Name: rubygem-mocha -Version: 1.2.1 +Version: 1.3.0 Release: 0 %define mod_name mocha %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{rubygem gem2rpm} -BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 +BuildRequires: %{ruby >= 1.8.7} +BuildRequires: %{rubygem gem2rpm} Url: http://gofreerange.com/mocha/docs -Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: Mocking and stubbing library License: MIT and BSD-2-Clause ++++++ mocha-1.2.1.gem -> mocha-1.3.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-10-15 15:09:06.000000000 +0200 +++ new/README.md 2017-08-24 23:44:56.000000000 +0200 @@ -1,4 +1,4 @@ -## Mocha [![build status](https://secure.travis-ci.org/freerange/mocha.png)](https://secure.travis-ci.org/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.png)](http://badge.fury.io/rb/mocha) [![OpenCollective](https://opencollective.com/mocha/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/mocha/sponsors/badge.svg)](#sponsors) +## Mocha [![Build Status](https://travis-ci.org/freerange/mocha.svg?branch=master)](https://travis-ci.org/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.png)](http://badge.fury.io/rb/mocha) [![OpenCollective](https://opencollective.com/mocha/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/mocha/sponsors/badge.svg)](#sponsors) ### Description @@ -78,7 +78,7 @@ ##### RSpec -Assuming you are using the `rspec-rails` gem: +RSpec includes a mocha adapter. Just tell RSpec you want to mock with `:mocha`: ```ruby # Gemfile in Rails app @@ -110,6 +110,7 @@ #### Known Issues * In Mocha v1.2.0 there is a scenario where stubbing a class method originally defined in a module hangs the Ruby interpreter due to [a bug in Ruby v2.3.1](https://bugs.ruby-lang.org/issues/12832). See #272. This was fixed in Mocha v1.2.1. +* Since v1.1.0 Mocha has used prepended modules internally for stubbing methods. There is [an obscure Ruby bug](https://bugs.ruby-lang.org/issues/12876) in many (but not all) versions of Ruby between v2.0 & v2.3 which under certain circumstances may cause your Ruby interpreter to hang. See the Ruby bug report for more details. The bug has been fixed in Ruby v2.3.3 & v2.4.0. * Stubbing an aliased class method, where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby 1.8.x. See stub_method_defined_on_module_and_aliased_test.rb for an example of this behaviour. * 0.13.x versions cause a harmless, but annoying, deprecation warning when used with Rails 3.2.0-3.2.12, 3.1.0-3.1.10 & 3.0.0-3.0.19. * 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115. @@ -281,7 +282,7 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contributors). -###Backers +### Backers Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/mocha#backer)] @@ -317,6 +318,7 @@ <a href="https://opencollective.com/mocha/backer/29/website" target="_blank"><img src="https://opencollective.com/mocha/backer/29/avatar.svg"></a> ### Sponsors + Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/mocha#sponsor)] <a href="https://opencollective.com/mocha/sponsor/0/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/0/avatar.svg"></a> @@ -354,6 +356,35 @@ * [Serbo-Croatian](http://science.webhostinggeeks.com/mocha) by [WHG Team](http://webhostinggeeks.com/). (may be out-of-date) +### Releasing a new version + +* Update the RELEASE.md file with a summary of changes +* Bump the version in `lib/mocha/version.rb` +* Commit & push to Github +* Check Travis CI build is passing - https://travis-ci.org/freerange/mocha + +* Sign in to rubygems.org and find API key - https://rubygems.org/profile/edit + +```bash +$ curl -u james@floehopper.org https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials` +``` + +* Sign in to Google Analytics - https://analytics.google.com/analytics/web/ +* Find the web property ID for Go Free Range Ltd > Mocha Documentation (UA-45002715-2) + +```bash +$ MOCHA_GENERATE_DOCS=true bundle install + +$ MOCHA_GENERATE_DOCS=true GOOGLE_ANALYTICS_WEB_PROPERTY_ID=UA-45002715-2 rake release +mocha 1.2.0 built to pkg/mocha-1.2.0.gem. +Tagged v1.2.0. +Pushed git commits and tags. +Pushed mocha 1.2.0 to rubygems.org. +[runs tests] +[generates docs] +[deploys docs] +``` + ### History Mocha was initially harvested from projects at [Reevoo](http://www.reevoo.com/). It's syntax is heavily based on that of [jMock](http://www.jmock.org). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/RELEASE.md new/RELEASE.md --- old/RELEASE.md 2016-10-15 15:09:06.000000000 +0200 +++ new/RELEASE.md 2017-08-24 23:44:56.000000000 +0200 @@ -1,5 +1,28 @@ # Release Notes +## 1.3.0 + +* Ensure all tests run individually - thanks to @chrisroos (#267) +* Update Travis CI build status badge to show master branch status (#264) +* Correct RSpec section of the README - thanks to @myronmarston (0cc039c8) +* Fix pretty printing of quotes in `String#mocha_inspect` (#215 & #223) +* Add release instructions to README - thanks to @chrisroos (70a5febd & 3c664df7) +* Require at least Ruby v1.8.7 in gemspec - thanks to @knappe (3e20be8e) +* Remove redundant InstanceMethod#method_exists? - thanks to @chrisroos (8f58eddf) +* Reduce risk of hitting bug 12832 in Ruby v2.3 - thanks to @chrisroos (#277 & eca7560c) +* Fix JRuby build - thanks to @headius (jruby/jruby#4250) & @chrisroos (#274) +* Add latest stable version of JRuby to Travis CI build matrix (#288) +* Fix Ruby v1.8.7 builds on Travis CI (928b5a40 & 460dce5b) +* Deprecate passing block to mock object constructor (#290) +* Add a known issue to README for Ruby bug 12876 (#276) +* Add Ruby 2.4 and ruby-head to Travis CI build matrix - thanks to @junaruga (#297) +* Fix `Mocha::ParameterMatchers#includes` for `Array` values - thanks to @timcraft (#302) +* Use faster container-based virtual environments for Travis CI builds (#305) +* Rename `Mocha::ParameterMatchers::QueryStringMatches` to `QueryString` (#306) +* Handle blank parameter value for query string matcher - thanks to @weynsee (#303 & #304) +* Rename `Mocha::ParameterMatchers::QueryString` -> `EquivalentUri` (#307) +* Use `do ... end` instead of `{ ... }` in acceptance tests - thanks to @chrisroos (#294) + ## 1.2.1 * Fixed #272. Workaround Ruby bug 12832 which caused interpreter to hang. See https://bugs.ruby-lang.org/issues/12832. Thanks to @chrisroos & @petems (6f1c8b9b, #273). Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/any_instance_method.rb new/lib/mocha/any_instance_method.rb --- old/lib/mocha/any_instance_method.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/any_instance_method.rb 2017-08-24 23:44:56.000000000 +0200 @@ -16,11 +16,11 @@ def hide_original_method if @original_visibility = method_visibility(method) begin - @original_method = stubbee.instance_method(method) if RUBY_V2_PLUS @definition_target = PrependedModule.new stubbee.__send__ :prepend, @definition_target else + @original_method = stubbee.instance_method(method) if @original_method && @original_method.owner == stubbee stubbee.send(:remove_method, method) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/api.rb new/lib/mocha/api.rb --- old/lib/mocha/api.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/api.rb 2017-08-24 23:44:56.000000000 +0200 @@ -25,7 +25,9 @@ # # @param [String] name identifies mock object in error messages. # @param [Hash] expected_methods_vs_return_values expected method name symbols as keys and corresponding return values as values - these expectations are setup as if {Mock#expects} were called multiple times. - # @yield optional block to be evaluated against the mock object instance, giving an alternative way to setup expectations. + # @yield optional block to be evaluated in the context of the mock object instance, giving an alternative way to setup stubbed methods. + # @yield note that the block is evaulated by calling Mock#instance_eval and so things like instance variables declared in the test will not be available within the block. + # @yield deprecated: use Object#tap or define stubs/expectations with an explicit receiver instead. # @return [Mock] a new mock object # # @overload def mock(name, &block) @@ -39,7 +41,7 @@ # assert motor.stop # # an error will be raised unless both Motor#start and Motor#stop have been called # end - # @example Using the optional block to setup expectations & stubbed methods. + # @example Using the optional block to setup expectations & stubbed methods [deprecated]. # def test_motor_starts_and_stops # motor = mock('motor') do # expects(:start).with(100.rpm).returns(true) @@ -61,7 +63,9 @@ # # @param [String] name identifies mock object in error messages. # @param [Hash] stubbed_methods_vs_return_values stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if {Mock#stubs} were called multiple times. - # @yield optional block to be evaluated against the mock object instance, giving an alternative way to setup stubbed methods. + # @yield optional block to be evaluated in the context of the mock object instance, giving an alternative way to setup stubbed methods. + # @yield note that the block is evaulated by calling Mock#instance_eval and so things like instance variables declared in the test will not be available within the block. + # @yield deprecated: use Object#tap or define stubs/expectations with an explicit receiver instead. # @return [Mock] a new mock object # # @overload def stub(name, &block) @@ -76,7 +80,7 @@ # # an error will not be raised even if either Motor#start or Motor#stop has not been called # end # - # @example Using the optional block to setup expectations & stubbed methods. + # @example Using the optional block to setup expectations & stubbed methods [deprecated]. # def test_motor_starts_and_stops # motor = stub('motor') do # expects(:start).with(100.rpm).returns(true) @@ -98,7 +102,9 @@ # # @param [String] name identifies mock object in error messages. # @param [Hash] stubbed_methods_vs_return_values stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if {Mock#stubs} were called multiple times. - # @yield optional block to be evaluated against the mock object instance, giving an alternative way to setup stubbed methods. + # @yield optional block to be evaluated in the context of the mock object instance, giving an alternative way to setup stubbed methods. + # @yield note that the block is evaulated by calling Mock#instance_eval and so things like instance variables declared in the test will not be available within the block. + # @yield deprecated: use Object#tap or define stubs/expectations with an explicit receiver instead. # @return [Mock] a new mock object # # @overload def stub_everything(name, &block) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/inspect.rb new/lib/mocha/inspect.rb --- old/lib/mocha/inspect.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/inspect.rb 2017-08-24 23:44:56.000000000 +0200 @@ -10,12 +10,6 @@ end end - module StringMethods - def mocha_inspect - inspect.gsub(/\"/, "'") - end - end - module ArrayMethods def mocha_inspect "[#{collect { |member| member.mocha_inspect }.join(', ')}]" @@ -46,10 +40,6 @@ include Mocha::ObjectMethods end -class String - include Mocha::StringMethods -end - class Array include Mocha::ArrayMethods end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/instance_method.rb new/lib/mocha/instance_method.rb --- old/lib/mocha/instance_method.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/instance_method.rb 2017-08-24 23:44:56.000000000 +0200 @@ -3,14 +3,6 @@ module Mocha class InstanceMethod < ClassMethod - - def method_exists?(method) - return true if stubbee.public_methods(false).include?(method) - return true if stubbee.protected_methods(false).include?(method) - return true if stubbee.private_methods(false).include?(method) - return false - end - end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/mock.rb new/lib/mocha/mock.rb --- old/lib/mocha/mock.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/mock.rb 2017-08-24 23:44:56.000000000 +0200 @@ -8,6 +8,7 @@ require 'mocha/unexpected_invocation' require 'mocha/argument_iterator' require 'mocha/expectation_error_factory' +require 'mocha/deprecation' module Mocha @@ -259,7 +260,10 @@ @everything_stubbed = false @responder = nil @unexpected_invocation = nil - instance_eval(&block) if block + if block + Deprecation.warning('Passing a block is deprecated. Use Object#tap or define stubs/expectations with an explicit receiver instead.') + instance_eval(&block) + end end # @private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/parameter_matchers/equivalent_uri.rb new/lib/mocha/parameter_matchers/equivalent_uri.rb --- old/lib/mocha/parameter_matchers/equivalent_uri.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/mocha/parameter_matchers/equivalent_uri.rb 2017-08-24 23:44:56.000000000 +0200 @@ -0,0 +1,67 @@ +require 'mocha/deprecation' +require 'mocha/parameter_matchers/base' +require 'uri' +require 'cgi' + +module Mocha + module ParameterMatchers + + # Matches a URI without regard to the ordering of parameters in the query string. + # + # @param [String] uri URI to match. + # @return [EquivalentUri] parameter matcher. + # + # @see Expectation#with + # + # @example Actual URI is equivalent. + # object = mock() + # object.expects(:method_1).with(equivalent_uri('http://example.com/foo?a=1&b=2)) + # object.method_1('http://example.com/foo?b=2&a=1') + # # no error raised + # + # @example Actual URI is not equivalent. + # object = mock() + # object.expects(:method_1).with(equivalent_uri('http://example.com/foo?a=1&b=2)) + # object.method_1('http://example.com/foo?a=1&b=3') + # # error raised, because the query parameters were different + def equivalent_uri(uri) + EquivalentUri.new(uri) + end + + # @deprecated Use {#equivalent_uri} instead. + def has_equivalent_query_string(uri) + Mocha::Deprecation.warning("`has_equivalent_query_string` is deprecated. Please use `equivalent_uri` instead.") + + equivalent_uri(uri) + end + + # Parameter matcher which matches URIs with equivalent query strings. + class EquivalentUri < Base + + # @private + def initialize(uri) + @uri = URI.parse(uri) + end + + # @private + def matches?(available_parameters) + actual = explode(URI.parse(available_parameters.shift)) + expected = explode(@uri) + actual == expected + end + + # @private + def mocha_inspect + "equivalent_uri(#{@uri.mocha_inspect})" + end + + private + # @private + def explode(uri) + query_hash = CGI.parse(uri.query || '') + URI::Generic::COMPONENT.inject({}){ |h, k| h.merge(k => uri.__send__(k)) }.merge(:query => query_hash) + end + + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/parameter_matchers/includes.rb new/lib/mocha/parameter_matchers/includes.rb --- old/lib/mocha/parameter_matchers/includes.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/parameter_matchers/includes.rb 2017-08-24 23:44:56.000000000 +0200 @@ -80,7 +80,8 @@ return false unless parameter.respond_to?(:include?) if @items.size == 1 if parameter.respond_to?(:any?) && !parameter.is_a?(String) - return parameter.any? { |(p,_)| @items.first.to_matcher.matches?([p]) } + parameter = parameter.keys if parameter.is_a?(Hash) + return parameter.any? { |p| @items.first.to_matcher.matches?([p]) } else return parameter.include?(@items.first) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/parameter_matchers/query_string.rb new/lib/mocha/parameter_matchers/query_string.rb --- old/lib/mocha/parameter_matchers/query_string.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/parameter_matchers/query_string.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -require 'mocha/parameter_matchers/base' -require 'uri' - -module Mocha - module ParameterMatchers - - # Matches a URI without regard to the ordering of parameters in the query string. - # - # @param [String] uri URI to match. - # @return [QueryStringMatches] parameter matcher. - # - # @see Expectation#with - # - # @example Actual URI has equivalent query string. - # object = mock() - # object.expects(:method_1).with(has_equivalent_query_string('http://example.com/foo?a=1&b=2)) - # object.method_1('http://example.com/foo?b=2&a=1') - # # no error raised - # - # @example Actual URI does not have equivalent query string. - # object = mock() - # object.expects(:method_1).with(has_equivalent_query_string('http://example.com/foo?a=1&b=2)) - # object.method_1('http://example.com/foo?a=1&b=3') - # # error raised, because the query parameters were different - def has_equivalent_query_string(uri) - QueryStringMatches.new(uri) - end - - # Parameter matcher which matches URIs with equivalent query strings. - class QueryStringMatches < Base - - # @private - def initialize(uri) - @uri = URI.parse(uri) - end - - # @private - def matches?(available_parameters) - actual = explode(URI.parse(available_parameters.shift)) - expected = explode(@uri) - actual == expected - end - - # @private - def mocha_inspect - "has_equivalent_query_string(#{@uri.mocha_inspect})" - end - - private - # @private - def explode(uri) - query_hash = (uri.query || '').split('&').inject({}){ |h, kv| h.merge(Hash[*kv.split('=')]) } - URI::Generic::COMPONENT.inject({}){ |h, k| h.merge(k => uri.__send__(k)) }.merge(:query => query_hash) - end - - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/parameter_matchers.rb new/lib/mocha/parameter_matchers.rb --- old/lib/mocha/parameter_matchers.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/parameter_matchers.rb 2017-08-24 23:44:56.000000000 +0200 @@ -25,4 +25,4 @@ require 'mocha/parameter_matchers/regexp_matches' require 'mocha/parameter_matchers/responds_with' require 'mocha/parameter_matchers/yaml_equivalent' -require 'mocha/parameter_matchers/query_string' +require 'mocha/parameter_matchers/equivalent_uri' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mocha/version.rb new/lib/mocha/version.rb --- old/lib/mocha/version.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/lib/mocha/version.rb 2017-08-24 23:44:56.000000000 +0200 @@ -1,3 +1,3 @@ module Mocha - VERSION = "1.2.1" + VERSION = "1.3.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-10-15 15:09:06.000000000 +0200 +++ new/metadata 2017-08-24 23:44:56.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: mocha version: !ruby/object:Gem::Version - version: 1.2.1 + version: 1.3.0 platform: ruby authors: - James Mead autorequire: bindir: bin cert_chain: [] -date: 2016-10-15 00:00:00.000000000 Z +date: 2017-08-24 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: metaclass @@ -194,6 +194,7 @@ - lib/mocha/parameter_matchers/anything.rb - lib/mocha/parameter_matchers/base.rb - lib/mocha/parameter_matchers/equals.rb +- lib/mocha/parameter_matchers/equivalent_uri.rb - lib/mocha/parameter_matchers/has_entries.rb - lib/mocha/parameter_matchers/has_entry.rb - lib/mocha/parameter_matchers/has_key.rb @@ -205,7 +206,6 @@ - lib/mocha/parameter_matchers/not.rb - lib/mocha/parameter_matchers/object.rb - lib/mocha/parameter_matchers/optionally.rb -- lib/mocha/parameter_matchers/query_string.rb - lib/mocha/parameter_matchers/regexp_matches.rb - lib/mocha/parameter_matchers/responds_with.rb - lib/mocha/parameter_matchers/yaml_equivalent.rb @@ -330,6 +330,7 @@ - test/unit/parameter_matchers/any_of_test.rb - test/unit/parameter_matchers/anything_test.rb - test/unit/parameter_matchers/equals_test.rb +- test/unit/parameter_matchers/equivalent_uri_test.rb - test/unit/parameter_matchers/has_entries_test.rb - test/unit/parameter_matchers/has_entry_test.rb - test/unit/parameter_matchers/has_key_test.rb @@ -368,7 +369,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: '0' + version: 1.8.7 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -376,7 +377,7 @@ version: '0' requirements: [] rubyforge_project: mocha -rubygems_version: 2.5.1 +rubygems_version: 2.6.12 signing_key: specification_version: 3 summary: Mocking and stubbing library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mocha.gemspec new/mocha.gemspec --- old/mocha.gemspec 2016-10-15 15:09:06.000000000 +0200 +++ new/mocha.gemspec 2017-08-24 23:44:56.000000000 +0200 @@ -7,6 +7,7 @@ s.name = "mocha" s.version = Mocha::VERSION s.licenses = ['MIT', 'BSD-2-Clause'] + s.required_ruby_version = '>= 1.8.7' s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Mead"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/failure_messages_test.rb new/test/acceptance/failure_messages_test.rb --- old/test/acceptance/failure_messages_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/failure_messages_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -58,7 +58,7 @@ test_result = run_as_test do 'Foo'.expects(:bar) end - assert_match Regexp.new("'Foo'"), test_result.failures[0].message + assert_match Regexp.new(%{"Foo"}), test_result.failures[0].message end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/mock_with_initializer_block_test.rb new/test/acceptance/mock_with_initializer_block_test.rb --- old/test/acceptance/mock_with_initializer_block_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/mock_with_initializer_block_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -1,5 +1,6 @@ require File.expand_path('../acceptance_test_helper', __FILE__) require 'mocha/setup' +require 'deprecation_disabler' class MockWithInitializerBlockTest < Mocha::TestCase @@ -15,35 +16,41 @@ def test_should_expect_two_method_invocations_and_receive_both_of_them test_result = run_as_test do - mock = mock() do - expects(:method_1) - expects(:method_2) + DeprecationDisabler.disable_deprecations do + mock = mock() do + expects(:method_1) + expects(:method_2) + end + mock.method_1 + mock.method_2 end - mock.method_1 - mock.method_2 end assert_passed(test_result) end def test_should_expect_two_method_invocations_but_receive_only_one_of_them test_result = run_as_test do - mock = mock() do - expects(:method_1) - expects(:method_2) + DeprecationDisabler.disable_deprecations do + mock = mock() do + expects(:method_1) + expects(:method_2) + end + mock.method_1 end - mock.method_1 end assert_failed(test_result) end def test_should_stub_methods test_result = run_as_test do - mock = mock() do - stubs(:method_1).returns(1) - stubs(:method_2).returns(2) + DeprecationDisabler.disable_deprecations do + mock = mock() do + stubs(:method_1).returns(1) + stubs(:method_2).returns(2) + end + assert_equal 1, mock.method_1 + assert_equal 2, mock.method_2 end - assert_equal 1, mock.method_1 - assert_equal 2, mock.method_2 end assert_passed(test_result) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/parameter_matcher_test.rb new/test/acceptance/parameter_matcher_test.rb --- old/test/acceptance/parameter_matcher_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/parameter_matcher_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -243,60 +243,24 @@ assert_failed(test_result) end - def test_should_match_parameter_that_has_identical_query_string + def test_should_match_parameter_that_is_equivalent_uri test_result = run_as_test do mock = mock() - mock.expects(:method).with(has_equivalent_query_string('http://example.com/foo?a=1&b=2')) + mock.expects(:method).with(equivalent_uri('http://example.com/foo?b=2&a=1')) mock.method('http://example.com/foo?a=1&b=2') end assert_passed(test_result) end - def test_should_match_parameter_that_has_rearranged_query_string + def test_should_not_match_parameter_that_is_not_equivalent test_result = run_as_test do mock = mock() - mock.expects(:method).with(has_equivalent_query_string('http://example.com/foo?b=2&a=1')) + mock.expects(:method).with(equivalent_uri('http://example.com/foo?a=1')) mock.method('http://example.com/foo?a=1&b=2') end - assert_passed(test_result) - end - - def test_should_not_match_parameter_that_does_not_have_the_same_query_parameters - test_result = run_as_test do - mock = mock() - mock.expects(:method).with(has_equivalent_query_string('http://example.com/foo?a=1')) - mock.method('http://example.com/foo?a=1&b=2') - end - assert_failed(test_result) - end - - def test_should_not_match_parameter_that_has_no_query_parameters_when_they_are_expected - test_result = run_as_test do - mock = mock() - mock.expects(:method).with(has_equivalent_query_string('http://example.com/foo')) - mock.method('http://example.com/foo?a=1&b=2') - end - assert_failed(test_result) - end - - def test_should_not_match_parameter_that_has_the_same_query_string_bit_which_differs_otherwise - test_result = run_as_test do - mock = mock() - mock.expects(:method).with(has_equivalent_query_string('http://a.example.com/foo?a=1&b=2')) - mock.method('http://b.example.com/foo?a=1&b=2') - end assert_failed(test_result) end - def test_should_match_parameter_with_no_domain_or_scheme - test_result = run_as_test do - mock = mock() - mock.expects(:method).with(has_equivalent_query_string('/foo?a=1&b=2')) - mock.method('/foo?a=1&b=2') - end - assert_passed(test_result) - end - def test_should_match_parameter_when_value_is_divisible_by_four test_result = run_as_test do mock = mock() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/sequence_test.rb new/test/acceptance/sequence_test.rb --- old/test/acceptance/sequence_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/sequence_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -148,7 +148,7 @@ mock.first end assert_failed(test_result) - assert_match Regexp.new("in sequence 'one'"), test_result.failures.first.message + assert_match Regexp.new(%{in sequence "one"}), test_result.failures.first.message end def test_should_allow_expectations_to_be_in_more_than_one_sequence @@ -166,8 +166,8 @@ mock.second end assert_failed(test_result) - assert_match Regexp.new("in sequence 'one'"), test_result.failures.first.message - assert_match Regexp.new("in sequence 'two'"), test_result.failures.first.message + assert_match Regexp.new(%{in sequence "one"}), test_result.failures.first.message + assert_match Regexp.new(%{in sequence "two"}), test_result.failures.first.message end def test_should_have_shortcut_for_expectations_to_be_in_more_than_one_sequence @@ -185,8 +185,8 @@ mock.second end assert_failed(test_result) - assert_match Regexp.new("in sequence 'one'"), test_result.failures.first.message - assert_match Regexp.new("in sequence 'two'"), test_result.failures.first.message + assert_match Regexp.new(%{in sequence "one"}), test_result.failures.first.message + assert_match Regexp.new(%{in sequence "two"}), test_result.failures.first.message end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/stub_module_method_test.rb new/test/acceptance/stub_module_method_test.rb --- old/test/acceptance/stub_module_method_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/stub_module_method_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -14,7 +14,11 @@ end def test_should_stub_method_within_test - mod = Module.new { def self.my_module_method; :original_return_value; end } + mod = Module.new do + def self.my_module_method + :original_return_value + end + end test_result = run_as_test do mod.stubs(:my_module_method).returns(:new_return_value) assert_equal :new_return_value, mod.my_module_method @@ -23,7 +27,14 @@ end def test_should_leave_stubbed_public_method_unchanged_after_test - mod = Module.new { class << self; def my_module_method; :original_return_value; end; public :my_module_method; end } + mod = Module.new do + class << self + def my_module_method + :original_return_value + end + public :my_module_method + end + end run_as_test do mod.stubs(:my_module_method).returns(:new_return_value) end @@ -32,7 +43,17 @@ end def test_should_leave_stubbed_protected_method_unchanged_after_test - mod = Module.new { class << self; def my_module_method; :original_return_value; end; protected :my_module_method; def my_unprotected_module_method; my_module_method; end; end } + mod = Module.new do + class << self + def my_module_method + :original_return_value + end + protected :my_module_method + def my_unprotected_module_method + my_module_method + end + end + end run_as_test do mod.stubs(:my_module_method).returns(:new_return_value) end @@ -41,7 +62,14 @@ end def test_should_leave_stubbed_private_method_unchanged_after_test - mod = Module.new { class << self; def my_module_method; :original_return_value; end; private :my_module_method; end } + mod = Module.new do + class << self + def my_module_method + :original_return_value + end + private :my_module_method + end + end run_as_test do mod.stubs(:my_module_method).returns(:new_return_value) end @@ -50,7 +78,11 @@ end def test_should_reset_expectations_after_test - mod = Module.new { def self.my_module_method; :original_return_value; end } + mod = Module.new do + def self.my_module_method + :original_return_value + end + end run_as_test do mod.stubs(:my_module_method) end @@ -58,8 +90,14 @@ end def test_should_be_able_to_stub_a_superclass_method - supermod = Module.new { def self.my_superclass_method; :original_return_value; end } - mod = Module.new { include supermod } + supermod = Module.new do + def self.my_superclass_method + :original_return_value + end + end + mod = Module.new do + include supermod + end test_result = run_as_test do mod.stubs(:my_superclass_method).returns(:new_return_value) assert_equal :new_return_value, mod.my_superclass_method diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/stubba_test_result_test.rb new/test/acceptance/stubba_test_result_test.rb --- old/test/acceptance/stubba_test_result_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/stubba_test_result_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -16,7 +16,10 @@ def test_should_include_expectation_verification_in_assertion_count test_result = run_as_test do - object = Class.new { def message; end }.new + object = Class.new do + def message + end + end.new object.expects(:message) object.message end @@ -32,7 +35,10 @@ def test_should_not_include_stubbing_expectation_verification_in_assertion_count test_result = run_as_test do - object = Class.new { def message; end }.new + object = Class.new do + def message + end + end.new object.stubs(:message) object.message end @@ -41,7 +47,10 @@ def test_should_include_expectation_verification_failure_in_failure_count test_result = run_as_test do - object = Class.new { def message; end }.new + object = Class.new do + def message + end + end.new object.expects(:message) end assert_equal 1, test_result.failure_count diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/acceptance/stubbing_on_non_mock_object_test.rb new/test/acceptance/stubbing_on_non_mock_object_test.rb --- old/test/acceptance/stubbing_on_non_mock_object_test.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/acceptance/stubbing_on_non_mock_object_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -15,7 +15,10 @@ def test_should_allow_stubbing_method_on_non_mock_object Mocha::Configuration.allow(:stubbing_method_on_non_mock_object) - non_mock_object = Class.new { def existing_method; end } + non_mock_object = Class.new do + def existing_method + end + end test_result = run_as_test do non_mock_object.stubs(:existing_method) end @@ -25,7 +28,10 @@ def test_should_warn_on_stubbing_method_on_non_mock_object Mocha::Configuration.warn_when(:stubbing_method_on_non_mock_object) - non_mock_object = Class.new { def existing_method; end } + non_mock_object = Class.new do + def existing_method + end + end test_result = run_as_test do non_mock_object.stubs(:existing_method) end @@ -35,7 +41,10 @@ def test_should_prevent_stubbing_method_on_non_mock_object Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object) - non_mock_object = Class.new { def existing_method; end } + non_mock_object = Class.new do + def existing_method + end + end test_result = run_as_test do non_mock_object.stubs(:existing_method) end @@ -44,7 +53,10 @@ end def test_should_default_to_allow_stubbing_method_on_non_mock_object - non_mock_object = Class.new { def existing_method; end } + non_mock_object = Class.new do + def existing_method + end + end test_result = run_as_test do non_mock_object.stubs(:existing_method) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/deprecation_disabler.rb new/test/deprecation_disabler.rb --- old/test/deprecation_disabler.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/deprecation_disabler.rb 2017-08-24 23:44:57.000000000 +0200 @@ -12,4 +12,5 @@ end end + module_function :disable_deprecations end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/execution_point.rb new/test/execution_point.rb --- old/test/execution_point.rb 2016-10-15 15:09:06.000000000 +0200 +++ new/test/execution_point.rb 2017-08-24 23:44:57.000000000 +0200 @@ -10,14 +10,16 @@ @backtrace = backtrace end + def first_relevant_line_of_backtrace + @backtrace && (@backtrace.reject { |l| /\Aorg\/jruby\//.match(l) }.first || 'unknown:0') + end + def file_name - return "unknown" unless @backtrace && @backtrace.first - /\A(.*?):\d+/.match(@backtrace.first)[1] + /\A(.*?):\d+/.match(first_relevant_line_of_backtrace)[1] end def line_number - return "unknown" unless @backtrace && @backtrace.first - Integer(/\A.*?:(\d+)/.match(@backtrace.first)[1]) + Integer(/\A.*?:(\d+)/.match(first_relevant_line_of_backtrace)[1]) end def ==(other) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/any_instance_method_test.rb new/test/unit/any_instance_method_test.rb --- old/test/unit/any_instance_method_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/any_instance_method_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -76,6 +76,7 @@ klass.define_instance_method(:any_instance) { any_instance } method = AnyInstanceMethod.new(klass, :method_x) method.replace_instance_method(:restore_original_method) { } + method.replace_instance_method(:reset_mocha) { } method.define_instance_accessor(:remove_called) method.replace_instance_method(:remove_new_method) { self.remove_called = true } @@ -92,6 +93,7 @@ klass.define_instance_method(:any_instance) { any_instance } method = AnyInstanceMethod.new(klass, :method_x) method.replace_instance_method(:remove_new_method) { } + method.replace_instance_method(:reset_mocha) { } method.define_instance_accessor(:restore_called) method.replace_instance_method(:restore_original_method) { self.restore_called = true } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/array_inspect_test.rb new/test/unit/array_inspect_test.rb --- old/test/unit/array_inspect_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/array_inspect_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -10,7 +10,7 @@ def test_should_use_mocha_inspect_on_each_item array = [1, 2, "chris"] - assert_equal "[1, 2, 'chris']", array.mocha_inspect + assert_equal %{[1, 2, "chris"]}, array.mocha_inspect end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/class_method_test.rb new/test/unit/class_method_test.rb --- old/test/unit/class_method_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/class_method_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -11,6 +11,7 @@ unless RUBY_V2_PLUS def test_should_hide_original_method klass = Class.new { def self.method_x; end } + klass.__metaclass__.send(:alias_method, :_method, :method) method = ClassMethod.new(klass, :method_x) method.hide_original_method @@ -59,6 +60,7 @@ def test_should_restore_original_method klass = Class.new { def self.method_x; :original_result; end } + klass.__metaclass__.send(:alias_method, :_method, :method) method = ClassMethod.new(klass, :method_x) method.hide_original_method @@ -72,6 +74,7 @@ def test_should_restore_original_method_accepting_a_block_parameter klass = Class.new { def self.method_x(&block); block.call if block_given? ; end } + klass.__metaclass__.send(:alias_method, :_method, :method) method = ClassMethod.new(klass, :method_x) method.hide_original_method @@ -121,6 +124,7 @@ method = ClassMethod.new(klass, :method_x) mocha = build_mock klass.define_instance_method(:mocha) { mocha } + method.replace_instance_method(:reset_mocha) { } method.define_instance_accessor(:remove_called) method.replace_instance_method(:remove_new_method) { self.remove_called = true } @@ -134,6 +138,7 @@ mocha = build_mock klass.define_instance_method(:mocha) { mocha } method = ClassMethod.new(klass, :method_x) + method.replace_instance_method(:reset_mocha) { } method.define_instance_accessor(:restore_called) method.replace_instance_method(:restore_original_method) { self.restore_called = true } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/expectation_test.rb new/test/unit/expectation_test.rb --- old/test/unit/expectation_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/expectation_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -343,7 +343,7 @@ sequence_two = Sequence.new('two') expectation = Expectation.new(mock, :expected_method).with(1, 2, {'a' => true}, {:b => false}, [1, 2, 3]).in_sequence(sequence_one, sequence_two) assert !expectation.verified? - assert_match "mock.expected_method(1, 2, {'a' => true}, {:b => false}, [1, 2, 3]); in sequence 'one'; in sequence 'two'", expectation.mocha_inspect + assert_match %{mock.expected_method(1, 2, {"a" => true}, {:b => false}, [1, 2, 3]); in sequence "one"; in sequence "two"}, expectation.mocha_inspect end class FakeConstraint diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/hash_inspect_test.rb new/test/unit/hash_inspect_test.rb --- old/test/unit/hash_inspect_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/hash_inspect_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -10,7 +10,7 @@ def test_should_use_mocha_inspect_on_each_item hash = {:a => 'mocha'} - assert_equal "{:a => 'mocha'}", hash.mocha_inspect + assert_equal %{{:a => "mocha"}}, hash.mocha_inspect end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/mockery_test.rb new/test/unit/mockery_test.rb --- old/test/unit/mockery_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/mockery_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -2,10 +2,12 @@ require 'mocha/mockery' require 'mocha/state_machine' require 'mocha/expectation_error_factory' +require 'deprecation_disabler' class MockeryTest < Mocha::TestCase include Mocha + include DeprecationDisabler def test_should_build_instance_of_mockery mockery = Mockery.instance @@ -28,16 +30,20 @@ def test_should_raise_expectation_error_because_not_all_expectations_are_satisfied mockery = Mockery.new - mock_1 = mockery.named_mock('mock-1') { expects(:method_1) } - mock_2 = mockery.named_mock('mock-2') { expects(:method_2) } - 1.times { mock_1.method_1 } - 0.times { mock_2.method_2 } + disable_deprecations do + mock_1 = mockery.named_mock('mock-1') { expects(:method_1) } + mock_2 = mockery.named_mock('mock-2') { expects(:method_2) } + 1.times { mock_1.method_1 } + 0.times { mock_2.method_2 } + end assert_raises(ExpectationErrorFactory.exception_class) { mockery.verify } end def test_should_reset_list_of_mocks_on_teardown mockery = Mockery.new - mockery.unnamed_mock { expects(:my_method) } + disable_deprecations do + mockery.unnamed_mock { expects(:my_method) } + end mockery.teardown assert_nothing_raised(ExpectationErrorFactory.exception_class) { mockery.verify } end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parameter_matchers/equals_test.rb new/test/unit/parameter_matchers/equals_test.rb --- old/test/unit/parameter_matchers/equals_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/parameter_matchers/equals_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -19,7 +19,7 @@ def test_should_describe_matcher matcher = equals('x') - assert_equal "'x'", matcher.mocha_inspect + assert_equal %{"x"}, matcher.mocha_inspect end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parameter_matchers/equivalent_uri_test.rb new/test/unit/parameter_matchers/equivalent_uri_test.rb --- old/test/unit/parameter_matchers/equivalent_uri_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/unit/parameter_matchers/equivalent_uri_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -0,0 +1,51 @@ +require File.expand_path('../../../test_helper', __FILE__) +require 'deprecation_disabler' +require 'mocha/parameter_matchers/equivalent_uri' + +class EquivalentUriMatchesTest < Mocha::TestCase + + include Mocha::ParameterMatchers + include DeprecationDisabler + + def test_should_match_identical_uri + matcher = equivalent_uri('http://example.com/foo?a=1&b=2') + assert matcher.matches?(['http://example.com/foo?a=1&b=2']) + end + + def test_should_support_legacy_matcher_method + disable_deprecations do + matcher = has_equivalent_query_string('http://example.com/foo?a=1&b=2') + assert matcher.matches?(['http://example.com/foo?a=1&b=2']) + end + end + + def test_should_match_uri_with_rearranged_query_string + matcher = equivalent_uri('http://example.com/foo?b=2&a=1') + assert matcher.matches?(['http://example.com/foo?a=1&b=2']) + end + + def test_should_not_match_uri_with_different_query_string + matcher = equivalent_uri('http://example.com/foo?a=1') + assert !matcher.matches?(['http://example.com/foo?a=1&b=2']) + end + + def test_should_not_match_uri_when_no_query_string_expected + matcher = equivalent_uri('http://example.com/foo') + assert !matcher.matches?(['http://example.com/foo?a=1&b=2']) + end + + def test_should_not_match_uri_with_different_domain + matcher = equivalent_uri('http://a.example.com/foo?a=1&b=2') + assert !matcher.matches?(['http://b.example.com/foo?a=1&b=2']) + end + + def test_should_match_uri_without_scheme_and_domain + matcher = equivalent_uri('/foo?a=1&b=2') + assert matcher.matches?(['/foo?a=1&b=2']) + end + + def test_should_match_uri_with_query_string_containing_blank_value + matcher = equivalent_uri('http://example.com/foo?a=&b=2') + assert matcher.matches?(['http://example.com/foo?a=&b=2']) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parameter_matchers/has_entry_test.rb new/test/unit/parameter_matchers/has_entry_test.rb --- old/test/unit/parameter_matchers/has_entry_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/parameter_matchers/has_entry_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -31,12 +31,12 @@ def test_should_describe_matcher_with_key_value_pair matcher = has_entry(:key_1, 'value_1') - assert_equal "has_entry(:key_1 => 'value_1')", matcher.mocha_inspect + assert_equal %{has_entry(:key_1 => "value_1")}, matcher.mocha_inspect end def test_should_describe_matcher_with_entry matcher = has_entry(:key_1 => 'value_1') - assert_equal "has_entry(:key_1 => 'value_1')", matcher.mocha_inspect + assert_equal %{has_entry(:key_1 => "value_1")}, matcher.mocha_inspect end def test_should_match_hash_including_specified_entry_with_nested_key_matcher diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parameter_matchers/has_value_test.rb new/test/unit/parameter_matchers/has_value_test.rb --- old/test/unit/parameter_matchers/has_value_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/parameter_matchers/has_value_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -21,7 +21,7 @@ def test_should_describe_matcher matcher = has_value('value_1') - assert_equal "has_value('value_1')", matcher.mocha_inspect + assert_equal %{has_value("value_1")}, matcher.mocha_inspect end def test_should_match_hash_including_specified_value_with_nested_value_matcher diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parameter_matchers/includes_test.rb new/test/unit/parameter_matchers/includes_test.rb --- old/test/unit/parameter_matchers/includes_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/parameter_matchers/includes_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -15,6 +15,11 @@ assert matcher.matches?([[:x, :y, :z]]) end + def test_should_match_object_including_array_value + matcher = includes([:x]) + assert matcher.matches?([[[:x], [:y], [:z]]]) + end + def test_should_match_object_including_all_values matcher = includes(:x, :y, :z) assert matcher.matches?([[:x, :y, :z]]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/sequence_test.rb new/test/unit/sequence_test.rb --- old/test/unit/sequence_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/sequence_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -98,7 +98,7 @@ sequence = Sequence.new('wibble') expectation = FakeExpectation.new sequence.constrain_as_next_in_sequence(expectation) - assert_equal "in sequence 'wibble'", expectation.ordering_constraints[0].mocha_inspect + assert_equal %{in sequence "wibble"}, expectation.ordering_constraints[0].mocha_inspect end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/string_inspect_test.rb new/test/unit/string_inspect_test.rb --- old/test/unit/string_inspect_test.rb 2016-10-15 15:09:07.000000000 +0200 +++ new/test/unit/string_inspect_test.rb 2017-08-24 23:44:57.000000000 +0200 @@ -3,9 +3,9 @@ class StringInspectTest < Mocha::TestCase - def test_should_replace_escaped_quotes_with_single_quote + def test_should_use_default_inspect_method string = "my_string" - assert_equal "'my_string'", string.mocha_inspect + assert_equal %{"my_string"}, string.mocha_inspect end end
participants (1)
-
root@hilbert.suse.de