Hello community,

here is the log from the commit of package rubygem-mocha for openSUSE:Factory 
checked in at 2018-07-18 22:50:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-mocha (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-mocha.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-mocha"

Wed Jul 18 22:50:26 2018 rev:25 rq:621015 version:1.5.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-mocha/rubygem-mocha.changes      
2017-09-04 12:32:01.239804512 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-mocha.new/rubygem-mocha.changes 
2018-07-18 22:50:32.187638029 +0200
@@ -1,0 +2,12 @@
+Sat Apr  7 04:30:12 UTC 2018 - factory-a...@kulow.org
+
+- updated to version 1.5.0
+  no changelog found
+
+-------------------------------------------------------------------
+Wed Mar 21 05:29:49 UTC 2018 - factory-a...@kulow.org
+
+- updated to version 1.4.0
+  no changelog found
+
+-------------------------------------------------------------------

Old:
----
  mocha-1.3.0.gem

New:
----
  mocha-1.5.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-mocha.spec ++++++
--- /var/tmp/diff_new_pack.BbPgqk/_old  2018-07-18 22:50:33.759632817 +0200
+++ /var/tmp/diff_new_pack.BbPgqk/_new  2018-07-18 22:50:33.759632817 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-mocha
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 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,19 +24,19 @@
 #
 
 Name:           rubygem-mocha
-Version:        1.3.0
+Version:        1.5.0
 Release:        0
 %define mod_name mocha
 %define mod_full_name %{mod_name}-%{version}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  ruby-macros >= 5
 BuildRequires:  %{ruby >= 1.8.7}
 BuildRequires:  %{rubygem gem2rpm}
+BuildRequires:  ruby-macros >= 5
 Url:            http://gofreerange.com/mocha/docs
 Source:         https://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml
 Summary:        Mocking and stubbing library
-License:        MIT and BSD-2-Clause
+License:        MIT AND BSD-2-Clause
 Group:          Development/Languages/Ruby
 
 %description

++++++ mocha-1.3.0.gem -> mocha-1.5.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2017-08-24 23:44:56.000000000 +0200
+++ new/README.md       2018-04-06 19:01:27.000000000 +0200
@@ -33,7 +33,7 @@
 require 'rubygems'
 gem 'mocha'
 require 'minitest/unit'
-require 'mocha/mini_test'
+require 'mocha/minitest'
 ```
 
 #### Bundler
@@ -59,7 +59,7 @@
 
 # Elsewhere after Bundler has loaded gems e.g. after `require 'bundler/setup'`
 require "minitest/unit"
-require "mocha/mini_test"
+require "mocha/minitest"
 ```
 
 #### Rails
@@ -73,7 +73,7 @@
 gem 'mocha'
 
 # At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
-require 'mocha/mini_test'
+require 'mocha/minitest'
 ```
 
 ##### RSpec
@@ -104,7 +104,7 @@
 
 ```ruby
 # At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
-require 'mocha/mini_test'
+require 'mocha/minitest'
 ```
 
 #### Known Issues
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/RELEASE.md new/RELEASE.md
--- old/RELEASE.md      2017-08-24 23:44:56.000000000 +0200
+++ new/RELEASE.md      2018-04-06 19:01:27.000000000 +0200
@@ -1,5 +1,17 @@
 # Release Notes
 
+## 1.5.0
+
+* Prevent use of Mocha outside the context of a test/example - thanks to 
@andyw8 & @lzap (#327)
+
+## 1.4.0
+
+* Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
+* Display file and line number in deprecation warning - thanks to @chrisarcand 
(#310, #312 & #313)
+* Rename `mocha/mini_test.rb` to `mocha/minitest.rb` - thanks to @grosser 
(#320 & #322)
+* Fix warning when delegating to mock in Ruby 2.4 - thanks to @tjvc (#321 & 
#323)
+* Updates to Travis CI configuration 
([73af600..9732726](https://github.com/freerange/mocha/compare/73af600...9732726)
 & 0426e5e)
+
 ## 1.3.0
 
 * Ensure all tests run individually - thanks to @chrisroos (#267)
@@ -418,7 +430,7 @@
 
 ## 0.5.0
 
-- Parameter Matchers - I’ve added a few Hamcrest-style parameter matchers 
which are designed to be used inside Expectation#with. The following matchers 
are currently available: anything(), includes(), has_key(), has_value(), 
has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually 
to get rid of the nasty parameter_block option on Expectation#with.
+- Parameter Matchers - I've added a few Hamcrest-style parameter matchers 
which are designed to be used inside Expectation#with. The following matchers 
are currently available: anything(), includes(), has_key(), has_value(), 
has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually 
to get rid of the nasty parameter_block option on Expectation#with.
 
   object = mock()
   object.expects(:method).with(has_key('key_1'))
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/central.rb new/lib/mocha/central.rb
--- old/lib/mocha/central.rb    2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/central.rb    2018-04-06 19:01:27.000000000 +0200
@@ -2,6 +2,23 @@
 
   class Central
 
+    class Null < self
+
+      def initialize(&block)
+        super
+        @raise_not_initialized_error = block
+      end
+
+      def stub(*)
+        @raise_not_initialized_error.call
+      end
+
+      def unstub(*)
+        @raise_not_initialized_error.call
+      end
+
+    end
+
     attr_accessor :stubba_methods
 
     def initialize
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/deprecation.rb new/lib/mocha/deprecation.rb
--- old/lib/mocha/deprecation.rb        2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/deprecation.rb        2018-04-06 19:01:27.000000000 +0200
@@ -1,4 +1,4 @@
-require 'mocha/debug'
+require 'mocha/backtrace_filter'
 
 module Mocha
 
@@ -10,13 +10,16 @@
 
       def warning(message)
         @messages << message
-        $stderr.puts "\n*** Mocha deprecation warning: #{message}\n\n" unless 
mode == :disabled
-        $stderr.puts caller.join("\n  ") if mode == :debug
+        unless mode == :disabled
+          filter = BacktraceFilter.new
+          location = filter.filtered(caller)[0]
+          $stderr.puts "Mocha deprecation warning at #{location}: #{message}"
+        end
       end
 
     end
 
-    self.mode = Debug::OPTIONS['debug'] ? :debug : :enabled
+    self.mode = :enabled
     self.messages = []
 
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/error_with_filtered_backtrace.rb 
new/lib/mocha/error_with_filtered_backtrace.rb
--- old/lib/mocha/error_with_filtered_backtrace.rb      1970-01-01 
01:00:00.000000000 +0100
+++ new/lib/mocha/error_with_filtered_backtrace.rb      2018-04-06 
19:01:27.000000000 +0200
@@ -0,0 +1,17 @@
+require 'mocha/backtrace_filter'
+
+module Mocha
+
+  # @private
+  class ErrorWithFilteredBacktrace < StandardError
+
+    # @private
+    def initialize(message = nil, backtrace = [])
+      super(message)
+      filter = BacktraceFilter.new
+      set_backtrace(filter.filtered(backtrace))
+    end
+
+  end
+
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/hooks.rb new/lib/mocha/hooks.rb
--- old/lib/mocha/hooks.rb      2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/hooks.rb      2018-04-06 19:01:27.000000000 +0200
@@ -21,6 +21,7 @@
     #
     # This method should be called before each individual test starts 
(including before any "setup" code).
     def mocha_setup
+      Mockery.setup
     end
 
     # Verifies that all mock expectations have been met (only for use by 
authors of test libraries).
@@ -37,8 +38,6 @@
     # This method should be called after each individual test has finished 
(including after any "teardown" code).
     def mocha_teardown
       Mockery.teardown
-    ensure
-      Mockery.reset_instance
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/integration/mini_test/version_13.rb 
new/lib/mocha/integration/mini_test/version_13.rb
--- old/lib/mocha/integration/mini_test/version_13.rb   2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_13.rb   2018-04-06 
19:01:27.000000000 +0200
@@ -25,6 +25,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.name
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/integration/mini_test/version_140.rb 
new/lib/mocha/integration/mini_test/version_140.rb
--- old/lib/mocha/integration/mini_test/version_140.rb  2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_140.rb  2018-04-06 
19:01:27.000000000 +0200
@@ -25,6 +25,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.__name__
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/integration/mini_test/version_141.rb 
new/lib/mocha/integration/mini_test/version_141.rb
--- old/lib/mocha/integration/mini_test/version_141.rb  2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_141.rb  2018-04-06 
19:01:27.000000000 +0200
@@ -31,6 +31,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.__name__
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/mini_test/version_142_to_172.rb 
new/lib/mocha/integration/mini_test/version_142_to_172.rb
--- old/lib/mocha/integration/mini_test/version_142_to_172.rb   2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_142_to_172.rb   2018-04-06 
19:01:27.000000000 +0200
@@ -31,6 +31,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.__name__
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/integration/mini_test/version_200.rb 
new/lib/mocha/integration/mini_test/version_200.rb
--- old/lib/mocha/integration/mini_test/version_200.rb  2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_200.rb  2018-04-06 
19:01:27.000000000 +0200
@@ -31,6 +31,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.__name__
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/mini_test/version_201_to_222.rb 
new/lib/mocha/integration/mini_test/version_201_to_222.rb
--- old/lib/mocha/integration/mini_test/version_201_to_222.rb   2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_201_to_222.rb   2018-04-06 
19:01:27.000000000 +0200
@@ -31,6 +31,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.__send__ self.__name__
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/mini_test/version_2110_to_2111.rb 
new/lib/mocha/integration/mini_test/version_2110_to_2111.rb
--- old/lib/mocha/integration/mini_test/version_2110_to_2111.rb 2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_2110_to_2111.rb 2018-04-06 
19:01:27.000000000 +0200
@@ -32,6 +32,7 @@
               begin
                 @passed = nil
                 self.before_setup
+                mocha_setup
                 self.setup
                 self.after_setup
                 self.run_test self.__name__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/mini_test/version_2112_to_320.rb 
new/lib/mocha/integration/mini_test/version_2112_to_320.rb
--- old/lib/mocha/integration/mini_test/version_2112_to_320.rb  2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_2112_to_320.rb  2018-04-06 
19:01:27.000000000 +0200
@@ -35,6 +35,7 @@
               begin
                 @passed = nil
                 self.before_setup
+                mocha_setup
                 self.setup
                 self.after_setup
                 self.run_test self.__name__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/mini_test/version_230_to_2101.rb 
new/lib/mocha/integration/mini_test/version_230_to_2101.rb
--- old/lib/mocha/integration/mini_test/version_230_to_2101.rb  2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/mini_test/version_230_to_2101.rb  2018-04-06 
19:01:27.000000000 +0200
@@ -31,6 +31,7 @@
             begin
               begin
                 @passed = nil
+                mocha_setup
                 self.setup
                 self.run_setup_hooks
                 self.__send__ self.__name__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/integration/test_unit/gem_version_200.rb 
new/lib/mocha/integration/test_unit/gem_version_200.rb
--- old/lib/mocha/integration/test_unit/gem_version_200.rb      2017-08-24 
23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/gem_version_200.rb      2018-04-06 
19:01:27.000000000 +0200
@@ -26,6 +26,7 @@
               yield(Test::Unit::TestCase::STARTED, name)
               begin
                 begin
+                  mocha_setup
                   run_setup
                   __send__(@method_name)
                   mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/test_unit/gem_version_201_to_202.rb 
new/lib/mocha/integration/test_unit/gem_version_201_to_202.rb
--- old/lib/mocha/integration/test_unit/gem_version_201_to_202.rb       
2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/gem_version_201_to_202.rb       
2018-04-06 19:01:27.000000000 +0200
@@ -26,6 +26,7 @@
               yield(Test::Unit::TestCase::STARTED, name)
               begin
                 begin
+                  mocha_setup
                   run_setup
                   run_test
                   mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/test_unit/gem_version_203_to_220.rb 
new/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
--- old/lib/mocha/integration/test_unit/gem_version_203_to_220.rb       
2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/gem_version_203_to_220.rb       
2018-04-06 19:01:27.000000000 +0200
@@ -26,6 +26,7 @@
               yield(Test::Unit::TestCase::STARTED, name)
               begin
                 begin
+                  mocha_setup
                   run_setup
                   run_test
                   mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/test_unit/gem_version_230_to_250.rb 
new/lib/mocha/integration/test_unit/gem_version_230_to_250.rb
--- old/lib/mocha/integration/test_unit/gem_version_230_to_250.rb       
2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/gem_version_230_to_250.rb       
2018-04-06 19:01:27.000000000 +0200
@@ -28,6 +28,7 @@
               yield(Test::Unit::TestCase::STARTED_OBJECT, self)
               begin
                 begin
+                  mocha_setup
                   run_setup
                   run_test
                   run_cleanup
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb 
new/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
--- old/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb   
2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb   
2018-04-06 19:01:27.000000000 +0200
@@ -25,6 +25,7 @@
             @_result = result
             begin
               begin
+                mocha_setup
                 setup
                 __send__(@method_name)
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb 
new/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
--- old/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb   
2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb   
2018-04-06 19:01:27.000000000 +0200
@@ -25,6 +25,7 @@
             @_result = result
             begin
               begin
+                mocha_setup
                 setup
                 __send__(@method_name)
                 mocha_verify(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/mini_test.rb new/lib/mocha/mini_test.rb
--- old/lib/mocha/mini_test.rb  2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/mini_test.rb  2018-04-06 19:01:27.000000000 +0200
@@ -1,3 +1,5 @@
-require "mocha/integration/mini_test"
+require 'mocha/deprecation'
 
-Mocha::Integration::MiniTest.activate
+Mocha::Deprecation.warning("`require 'mocha/mini_test'` has been deprecated. 
Please use `require 'mocha/minitest' instead.")
+
+require 'mocha/minitest'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/minitest.rb new/lib/mocha/minitest.rb
--- old/lib/mocha/minitest.rb   1970-01-01 01:00:00.000000000 +0100
+++ new/lib/mocha/minitest.rb   2018-04-06 19:01:27.000000000 +0200
@@ -0,0 +1,3 @@
+require "mocha/integration/mini_test"
+
+Mocha::Integration::MiniTest.activate
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       2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/mock.rb       2018-04-06 19:01:27.000000000 +0200
@@ -9,6 +9,7 @@
 require 'mocha/argument_iterator'
 require 'mocha/expectation_error_factory'
 require 'mocha/deprecation'
+require 'mocha/ruby_version'
 
 module Mocha
 
@@ -314,7 +315,7 @@
     end
 
     # @private
-    def respond_to?(symbol, include_private = false)
+    def respond_to_missing?(symbol, include_private = false)
       if @responder then
         if @responder.method(:respond_to?).arity > 1
           @responder.respond_to?(symbol, include_private)
@@ -326,6 +327,13 @@
       end
     end
 
+    # @private
+    if PRE_RUBY_V19
+      def respond_to?(symbol, include_private = false)
+        respond_to_missing?(symbol, include_private)
+      end
+    end
+
     # @private
     def __verified__?(assertion_counter = nil)
       @expectations.verified?(assertion_counter)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/mockery.rb new/lib/mocha/mockery.rb
--- old/lib/mocha/mockery.rb    2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/mockery.rb    2018-04-06 19:01:27.000000000 +0200
@@ -7,16 +7,46 @@
 require 'mocha/logger'
 require 'mocha/configuration'
 require 'mocha/stubbing_error'
+require 'mocha/not_initialized_error'
 require 'mocha/expectation_error_factory'
 
 module Mocha
 
   class Mockery
 
+    class Null < self
+
+      def add_mock(*)
+        raise_not_initialized_error
+      end
+
+      def add_state_machine(*)
+        raise_not_initialized_error
+      end
+
+      def stubba
+        Central::Null.new(&method(:raise_not_initialized_error))
+      end
+
+      private
+
+      def raise_not_initialized_error
+        message = 'Mocha methods cannot be used outside the context of a test'
+        raise NotInitializedError.new(message, caller)
+      end
+
+    end
+
     class << self
 
       def instance
-        @instance ||= new
+        instances.last || Null.new
+      end
+
+      def setup
+        mockery = new
+        mockery.logger = instance.logger unless instances.empty?
+        @instances.push(mockery)
       end
 
       def verify(*args)
@@ -25,10 +55,15 @@
 
       def teardown
         instance.teardown
+      ensure
+        @instances.pop
+        @instances = nil if instances.empty?
       end
 
-      def reset_instance
-        @instance = nil
+      private
+
+      def instances
+        @instances ||= []
       end
 
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/not_initialized_error.rb 
new/lib/mocha/not_initialized_error.rb
--- old/lib/mocha/not_initialized_error.rb      1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/mocha/not_initialized_error.rb      2018-04-06 19:01:27.000000000 
+0200
@@ -0,0 +1,9 @@
+require 'mocha/error_with_filtered_backtrace'
+
+module Mocha
+
+  # Exception raised when Mocha has not been initialized, e.g. outside the
+  # context of a test.
+  class NotInitializedError < ErrorWithFilteredBacktrace; end
+
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mocha/stubbing_error.rb 
new/lib/mocha/stubbing_error.rb
--- old/lib/mocha/stubbing_error.rb     2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/stubbing_error.rb     2018-04-06 19:01:27.000000000 +0200
@@ -1,19 +1,10 @@
-require 'mocha/backtrace_filter'
+require 'mocha/error_with_filtered_backtrace'
 
 module Mocha
 
   # Exception raised when stubbing a particular method is not allowed.
   #
   # @see Configuration.prevent
-  class StubbingError < StandardError
-
-    # @private
-    def initialize(message = nil, backtrace = [])
-      super(message)
-      filter = BacktraceFilter.new
-      set_backtrace(filter.filtered(backtrace))
-    end
-
-  end
+  class StubbingError < ErrorWithFilteredBacktrace; end
 
 end
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    2017-08-24 23:44:56.000000000 +0200
+++ new/lib/mocha/version.rb    2018-04-06 19:01:27.000000000 +0200
@@ -1,3 +1,3 @@
 module Mocha
-  VERSION = "1.3.0"
+  VERSION = "1.5.0"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2017-08-24 23:44:56.000000000 +0200
+++ new/metadata        2018-04-06 19:01:27.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: mocha
 version: !ruby/object:Gem::Version
-  version: 1.3.0
+  version: 1.5.0
 platform: ruby
 authors:
 - James Mead
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2017-08-24 00:00:00.000000000 Z
+date: 2018-04-06 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: metaclass
@@ -141,6 +141,7 @@
 - lib/mocha/deprecation.rb
 - lib/mocha/detection/mini_test.rb
 - lib/mocha/detection/test_unit.rb
+- lib/mocha/error_with_filtered_backtrace.rb
 - lib/mocha/exception_raiser.rb
 - lib/mocha/expectation.rb
 - lib/mocha/expectation_error.rb
@@ -179,6 +180,7 @@
 - lib/mocha/logger.rb
 - lib/mocha/method_matcher.rb
 - lib/mocha/mini_test.rb
+- lib/mocha/minitest.rb
 - lib/mocha/mock.rb
 - lib/mocha/mockery.rb
 - lib/mocha/module_method.rb
@@ -186,6 +188,7 @@
 - lib/mocha/multiple_yields.rb
 - lib/mocha/names.rb
 - lib/mocha/no_yields.rb
+- lib/mocha/not_initialized_error.rb
 - lib/mocha/object_methods.rb
 - lib/mocha/parameter_matchers.rb
 - lib/mocha/parameter_matchers/all_of.rb
@@ -249,6 +252,7 @@
 - test/acceptance/parameter_matcher_test.rb
 - test/acceptance/partial_mocks_test.rb
 - test/acceptance/prepend_test.rb
+- test/acceptance/prevent_use_of_mocha_outside_test_test.rb
 - test/acceptance/raise_exception_test.rb
 - test/acceptance/return_value_test.rb
 - test/acceptance/sequence_test.rb
@@ -377,7 +381,7 @@
       version: '0'
 requirements: []
 rubyforge_project: mocha
-rubygems_version: 2.6.12
+rubygems_version: 2.6.11
 signing_key: 
 specification_version: 3
 summary: Mocking and stubbing library
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/acceptance/acceptance_test_helper.rb 
new/test/acceptance/acceptance_test_helper.rb
--- old/test/acceptance/acceptance_test_helper.rb       2017-08-24 
23:44:56.000000000 +0200
+++ new/test/acceptance/acceptance_test_helper.rb       2018-04-06 
19:01:27.000000000 +0200
@@ -27,13 +27,11 @@
     Mocha::Configuration.reset_configuration
     @logger = FakeLogger.new
     mockery = Mocha::Mockery.instance
-    @original_logger = mockery.logger
     mockery.logger = @logger
   end
 
   def teardown_acceptance_test
     Mocha::Configuration.reset_configuration
-    Mocha::Mockery.instance.logger = @original_logger
   end
 
   include Introspection::Assertions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/test/acceptance/prevent_use_of_mocha_outside_test_test.rb 
new/test/acceptance/prevent_use_of_mocha_outside_test_test.rb
--- old/test/acceptance/prevent_use_of_mocha_outside_test_test.rb       
1970-01-01 01:00:00.000000000 +0100
+++ new/test/acceptance/prevent_use_of_mocha_outside_test_test.rb       
2018-04-06 19:01:27.000000000 +0200
@@ -0,0 +1,79 @@
+require File.expand_path('../acceptance_test_helper', __FILE__)
+require 'mocha/setup'
+require 'mocha/not_initialized_error'
+
+class PreventUseOfMochaOutsideTestTest < Mocha::TestCase
+
+  include AcceptanceTest
+
+  def setup
+    setup_acceptance_test
+    mocha_teardown
+  end
+
+  def teardown
+    teardown_acceptance_test
+  end
+
+  def test_should_raise_exception_when_mock_called_outside_test
+    assert_raises(Mocha::NotInitializedError) { mock('object') }
+  end
+
+  def test_should_raise_exception_when_stub_called_outside_test
+    assert_raises(Mocha::NotInitializedError) { stub('object') }
+  end
+
+  def test_should_raise_exception_when_stub_everything_called_outside_test
+    assert_raises(Mocha::NotInitializedError) { stub_everything('object') }
+  end
+
+  def test_should_raise_exception_when_states_called_outside_test
+    assert_raises(Mocha::NotInitializedError) { states('state-machine') }
+  end
+
+  def test_should_raise_exception_when_expects_called_on_instance_outside_test
+    instance = Class.new.new
+    assert_raises(Mocha::NotInitializedError) { 
instance.expects(:expected_method) }
+  end
+
+  def test_should_raise_exception_when_expects_called_on_class_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { 
klass.expects(:expected_method) }
+  end
+
+  def 
test_should_raise_exception_when_expects_called_on_any_instance_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { 
klass.any_instance.expects(:expected_method) }
+  end
+
+  def test_should_raise_exception_when_stubs_called_on_instance_outside_test
+    instance = Class.new.new
+    assert_raises(Mocha::NotInitializedError) { 
instance.stubs(:expected_method) }
+  end
+
+  def test_should_raise_exception_when_stubs_called_on_class_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { klass.stubs(:expected_method) }
+  end
+
+  def 
test_should_raise_exception_when_stubs_called_on_any_instance_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { 
klass.any_instance.stubs(:expected_method) }
+  end
+
+  def test_should_raise_exception_when_unstub_called_on_instance_outside_test
+    instance = Class.new.new
+    assert_raises(Mocha::NotInitializedError) { 
instance.unstub(:expected_method) }
+  end
+
+  def test_should_raise_exception_when_unstub_called_on_class_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { klass.unstub(:expected_method) 
}
+  end
+
+  def 
test_should_raise_exception_when_unstub_called_on_any_instance_outside_test
+    klass = Class.new
+    assert_raises(Mocha::NotInitializedError) { 
klass.any_instance.unstub(:expected_method) }
+  end
+
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/integration/mini_test_test.rb 
new/test/integration/mini_test_test.rb
--- old/test/integration/mini_test_test.rb      2017-08-24 23:44:57.000000000 
+0200
+++ new/test/integration/mini_test_test.rb      2018-04-06 19:01:27.000000000 
+0200
@@ -1,6 +1,6 @@
 require File.expand_path('../../test_helper', __FILE__)
 
-require "mocha/mini_test"
+require "mocha/minitest"
 require "integration/shared_tests"
 
 class MiniTestTest < Mocha::TestCase
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  2017-08-24 23:44:57.000000000 +0200
+++ new/test/unit/class_method_test.rb  2018-04-06 19:01:27.000000000 +0200
@@ -179,10 +179,9 @@
   def test_should_return_mock_for_stubbee
     mocha = Object.new
     stubbee = Object.new
-    stubbee.define_instance_accessor(:mocha) { mocha }
-    stubbee.mocha = nil
+    stubbee.define_instance_method(:mocha) { mocha }
     method = ClassMethod.new(stubbee, :method_name)
-    assert_equal stubbee.mocha, method.mock
+    assert_equal mocha, method.mock
   end
 
   def test_should_not_match_if_other_object_has_a_different_class
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/unit/hooks_test.rb new/test/unit/hooks_test.rb
--- old/test/unit/hooks_test.rb 2017-08-24 23:44:57.000000000 +0200
+++ new/test/unit/hooks_test.rb 2018-04-06 19:01:27.000000000 +0200
@@ -1,10 +1,11 @@
 require File.expand_path('../../test_helper', __FILE__)
 require 'mocha/hooks'
+require 'mocha/mockery'
 
 class HooksTest < Mocha::TestCase
   class Mocha::Mockery
     class << self
-      attr_writer :instance
+      attr_writer :instances
     end
   end
 
@@ -19,11 +20,11 @@
 
   def 
test_ensure_mockery_instance_is_reset_even_when_an_exception_is_raised_in_mockery_teardown
     fake_test_case = Object.new.extend(Mocha::Hooks)
-    original_mockery = FakeMockery.new
-    Mocha::Mockery.instance = original_mockery
+    mockery = FakeMockery.new
+    Mocha::Mockery.instances = [mockery]
 
     fake_test_case.mocha_teardown rescue nil
 
-    assert_not_same Mocha::Mockery.instance, original_mockery
+    assert_kind_of Mocha::Mockery::Null, Mocha::Mockery.instance
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/unit/mock_test.rb new/test/unit/mock_test.rb
--- old/test/unit/mock_test.rb  2017-08-24 23:44:57.000000000 +0200
+++ new/test/unit/mock_test.rb  2018-04-06 19:01:27.000000000 +0200
@@ -334,6 +334,14 @@
     assert_match(/unexpected invocation/, e.message)
   end
 
+  unless PRE_RUBY_V19
+    def test_expectation_is_defined_on_mock
+      mock = build_mock
+      mock.expects(:method1)
+      assert defined? mock.method1
+    end
+  end
+
   private
 
   def build_mock
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       2017-08-24 23:44:57.000000000 +0200
+++ new/test/unit/mockery_test.rb       2018-04-06 19:01:27.000000000 +0200
@@ -9,7 +9,22 @@
   include Mocha
   include DeprecationDisabler
 
-  def test_should_build_instance_of_mockery
+  def setup
+    Mockery.setup
+  end
+
+  def teardown
+    Mockery.teardown
+  end
+
+  def test_should_return_null_mockery_if_not_setup
+    Mockery.teardown
+    mockery = Mockery.instance
+    assert_not_nil mockery
+    assert_kind_of Mockery::Null, mockery
+  end
+
+  def test_should_return_instance_of_mockery
     mockery = Mockery.instance
     assert_not_nil mockery
     assert_kind_of Mockery, mockery
@@ -23,7 +38,7 @@
 
   def test_should_expire_mockery_instance_cache
     mockery_1 = Mockery.instance
-    Mockery.reset_instance
+    Mockery.teardown
     mockery_2 = Mockery.instance
     assert_not_same mockery_1, mockery_2
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/unit/object_methods_test.rb 
new/test/unit/object_methods_test.rb
--- old/test/unit/object_methods_test.rb        2017-08-24 23:44:57.000000000 
+0200
+++ new/test/unit/object_methods_test.rb        2018-04-06 19:01:27.000000000 
+0200
@@ -1,14 +1,20 @@
 require File.expand_path('../../test_helper', __FILE__)
 require 'mocha/object_methods'
+require 'mocha/mockery'
 require 'mocha/mock'
 require 'mocha/expectation_error_factory'
 
 class ObjectMethodsTest < Mocha::TestCase
 
   def setup
+    Mocha::Mockery.setup
     @object = Object.new.extend(Mocha::ObjectMethods)
   end
 
+  def teardown
+    Mocha::Mockery.teardown
+  end
+
   def test_should_build_mocha_referring_to_self
     mocha = @object.mocha
     assert_not_nil mocha


Reply via email to