flexmock 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/README +1 -1
- data/Rakefile +4 -2
- data/lib/flexmock.rb +5 -1
- data/test/test_stubbing.rb +23 -0
- metadata +3 -3
    
        data/CHANGELOG
    CHANGED
    
    | @@ -1,5 +1,12 @@ | |
| 1 | 
            +
            2006-10-17  Jim Weirich  <jim@weirichhouse.org>
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            = Changes for FlexMock
         | 
| 2 4 |  | 
| 5 | 
            +
            == Pre-Version 0.4.2	
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * Fixed bug where multiple stubs of a class method were not
         | 
| 8 | 
            +
              properly restored.
         | 
| 9 | 
            +
            	
         | 
| 3 10 | 
             
            == Version 0.4.1
         | 
| 4 11 |  | 
| 5 12 | 
             
            * Removed include of Test::Unit::Assertions from Expectations.
         | 
    
        data/README
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -9,7 +9,7 @@ require 'rake/testtask' | |
| 9 9 | 
             
            CLEAN.include('*.tmp')
         | 
| 10 10 | 
             
            CLOBBER.include("html", 'pkg')
         | 
| 11 11 |  | 
| 12 | 
            -
            PKG_VERSION = '0.4. | 
| 12 | 
            +
            PKG_VERSION = '0.4.2'
         | 
| 13 13 |  | 
| 14 14 | 
             
            PKG_FILES = FileList[
         | 
| 15 15 | 
             
              '[A-Z]*',
         | 
| @@ -27,7 +27,9 @@ RDOC_FILES = FileList[ | |
| 27 27 | 
             
            ]
         | 
| 28 28 |  | 
| 29 29 |  | 
| 30 | 
            -
            task :default => [: | 
| 30 | 
            +
            task :default => [:test_all]
         | 
| 31 | 
            +
            task :test_all => [:test]
         | 
| 32 | 
            +
            task :ta => [:test_all]
         | 
| 31 33 |  | 
| 32 34 | 
             
            # Test Targets -------------------------------------------------------
         | 
| 33 35 |  | 
    
        data/lib/flexmock.rb
    CHANGED
    
    | @@ -973,6 +973,7 @@ class FlexMock | |
| 973 973 | 
             
                  @mock = mock
         | 
| 974 974 | 
             
                  @methods_to_restore = []
         | 
| 975 975 | 
             
                  @method_definitions = {}
         | 
| 976 | 
            +
                  @methods_proxied = []
         | 
| 976 977 | 
             
                end
         | 
| 977 978 |  | 
| 978 979 | 
             
                # Stub out the given method in the existing object and then let the 
         | 
| @@ -982,7 +983,10 @@ class FlexMock | |
| 982 983 | 
             
                  if @obj.methods.include?(method_name.to_s)
         | 
| 983 984 | 
             
                    @methods_to_restore << method_name
         | 
| 984 985 | 
             
                  end
         | 
| 985 | 
            -
                   | 
| 986 | 
            +
                  unless @methods_proxied.include?(method_name)
         | 
| 987 | 
            +
                    hide_existing_method(method_name)
         | 
| 988 | 
            +
                    @methods_proxied << method_name
         | 
| 989 | 
            +
                  end
         | 
| 986 990 | 
             
                  @mock.should_receive(method_name)
         | 
| 987 991 | 
             
                end
         | 
| 988 992 |  | 
    
        data/test/test_stubbing.rb
    CHANGED
    
    | @@ -69,6 +69,17 @@ class TestStubbing < Test::Unit::TestCase | |
| 69 69 | 
             
                stub_proxy.mock_teardown
         | 
| 70 70 | 
             
                assert_raise(NoMethodError) { obj.hi }
         | 
| 71 71 | 
             
              end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              def test_multiple_stubs_on_single_method_can_be_restored_missing_method
         | 
| 74 | 
            +
                obj = Object.new
         | 
| 75 | 
            +
                stub_proxy = flexstub(obj)
         | 
| 76 | 
            +
                stub_proxy.should_receive(:hi).with(1).once.and_return(:ok)
         | 
| 77 | 
            +
                stub_proxy.should_receive(:hi).with(2).once.and_return(:ok)
         | 
| 78 | 
            +
                assert_equal :ok, obj.hi(1)
         | 
| 79 | 
            +
                assert_equal :ok, obj.hi(2)
         | 
| 80 | 
            +
                stub_proxy.mock_teardown
         | 
| 81 | 
            +
                assert_raise(NoMethodError) { obj.hi }
         | 
| 82 | 
            +
              end
         | 
| 72 83 |  | 
| 73 84 | 
             
              def test_original_behavior_is_restored_when_multiple_methods_are_mocked
         | 
| 74 85 | 
             
                dog = Dog.new
         | 
| @@ -96,6 +107,18 @@ class TestStubbing < Test::Unit::TestCase | |
| 96 107 | 
             
                assert_equal :hello, obj.hi
         | 
| 97 108 | 
             
              end
         | 
| 98 109 |  | 
| 110 | 
            +
              def test_original_behavior_is_restored_on_singleton_methods_with_multiple_stubs
         | 
| 111 | 
            +
                obj = Object.new
         | 
| 112 | 
            +
                def obj.hi(n) "hello#{n}" end
         | 
| 113 | 
            +
                flexstub(obj).should_receive(:hi).with(1).once.and_return(:hola)
         | 
| 114 | 
            +
                flexstub(obj).should_receive(:hi).with(2).once.and_return(:hola)
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                assert_equal :hola, obj.hi(1)
         | 
| 117 | 
            +
                assert_equal :hola, obj.hi(2)
         | 
| 118 | 
            +
                flexstub(obj).mock_teardown
         | 
| 119 | 
            +
                assert_equal "hello3", obj.hi(3)
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 99 122 | 
             
              def test_original_behavior_is_restored_even_when_errors
         | 
| 100 123 | 
             
                flexstub(Dog).should_receive(:create).once.and_return(:mock)
         | 
| 101 124 | 
             
                flexmock_teardown rescue nil
         | 
    
        metadata
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            -
            rubygems_version: 0.9.0. | 
| 2 | 
            +
            rubygems_version: 0.9.0.6
         | 
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: flexmock
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 0.4. | 
| 7 | 
            -
            date: 2006- | 
| 6 | 
            +
              version: 0.4.2
         | 
| 7 | 
            +
            date: 2006-10-18 00:00:00 -04:00
         | 
| 8 8 | 
             
            summary: Simple and Flexible Mock Objects for Testing
         | 
| 9 9 | 
             
            require_paths: 
         | 
| 10 10 | 
             
            - lib
         |