mocha 0.3.2 → 0.3.3
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/Rakefile +1 -1
 - data/lib/smart_test_case.rb +1 -1
 - data/lib/smart_test_case/multiple_setup_and_teardown.rb +89 -91
 - data/lib/stubba.rb +1 -1
 - data/lib/stubba/instance_method.rb +1 -5
 - data/lib/stubba/setup_and_teardown.rb +17 -19
 - data/test/mocha/expectation_test.rb +0 -1
 - data/test/mocha_test_result_integration_test.rb +1 -1
 - data/test/smart_test_case/multiple_setup_and_teardown_test.rb +11 -11
 - data/test/stubba/instance_method_test.rb +7 -58
 - data/test/stubba/setup_and_teardown_test.rb +3 -3
 - data/test/stubba_acceptance_test.rb +1 -1
 - data/test/stubba_integration_test.rb +61 -24
 - data/test/stubba_test_result_integration_test.rb +2 -2
 - metadata +2 -2
 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/smart_test_case.rb
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'smart_test_case/multiple_setup_and_teardown'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
              include  
     | 
| 
      
 4 
     | 
    
         
            +
              include MultipleSetupAndTeardown unless ancestors.include?(MultipleSetupAndTeardown)
         
     | 
| 
       5 
5 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,125 +1,123 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module  
     | 
| 
       2 
     | 
    
         
            -
              module MultipleSetupAndTeardown
         
     | 
| 
      
 1 
     | 
    
         
            +
            module MultipleSetupAndTeardown
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
              def self.included(base)
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                base.class_eval do
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
                  def self.method_added(symbol)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    # disable until later
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                          setup_mocha
         
     | 
| 
       19 
     | 
    
         
            -
                        end
         
     | 
| 
       20 
     | 
    
         
            -
                      end
         
     | 
| 
       21 
     | 
    
         
            -
                    else
         
     | 
| 
       22 
     | 
    
         
            -
                      define_method(:setup_new) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  if method_defined?(:setup) then
         
     | 
| 
      
 12 
     | 
    
         
            +
                    alias_method :setup_original, :setup
         
     | 
| 
      
 13 
     | 
    
         
            +
                    define_method(:setup_new) do
         
     | 
| 
      
 14 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 15 
     | 
    
         
            +
                        setup_original
         
     | 
| 
      
 16 
     | 
    
         
            +
                      ensure
         
     | 
| 
       23 
17 
     | 
    
         
             
                        setup_mocha
         
     | 
| 
       24 
18 
     | 
    
         
             
                      end
         
     | 
| 
       25 
19 
     | 
    
         
             
                    end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                       
     | 
| 
       37 
     | 
    
         
            -
                    else
         
     | 
| 
       38 
     | 
    
         
            -
                      define_method(:teardown_new) do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  else
         
     | 
| 
      
 21 
     | 
    
         
            +
                    define_method(:setup_new) do
         
     | 
| 
      
 22 
     | 
    
         
            +
                      setup_mocha
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  alias_method :setup, :setup_new
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  if method_defined?(:teardown) then
         
     | 
| 
      
 28 
     | 
    
         
            +
                    alias_method :teardown_original, :teardown
         
     | 
| 
      
 29 
     | 
    
         
            +
                    define_method(:teardown_new) do
         
     | 
| 
      
 30 
     | 
    
         
            +
                      begin
         
     | 
| 
       39 
31 
     | 
    
         
             
                        teardown_mocha
         
     | 
| 
      
 32 
     | 
    
         
            +
                      ensure
         
     | 
| 
      
 33 
     | 
    
         
            +
                        teardown_original
         
     | 
| 
       40 
34 
     | 
    
         
             
                      end
         
     | 
| 
       41 
35 
     | 
    
         
             
                    end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
                    define_method(:teardown_new) do
         
     | 
| 
      
 38 
     | 
    
         
            +
                      teardown_mocha
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                  alias_method :teardown, :teardown_new
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  def self.method_added(method)
         
     | 
| 
      
 44 
     | 
    
         
            +
                    case method
         
     | 
| 
      
 45 
     | 
    
         
            +
                    when :setup
         
     | 
| 
      
 46 
     | 
    
         
            +
                      unless method_defined?(:setup_added)
         
     | 
| 
      
 47 
     | 
    
         
            +
                        alias_method :setup_added, :setup
         
     | 
| 
      
 48 
     | 
    
         
            +
                        define_method(:setup) do
         
     | 
| 
      
 49 
     | 
    
         
            +
                          begin
         
     | 
| 
      
 50 
     | 
    
         
            +
                            setup_new
         
     | 
| 
      
 51 
     | 
    
         
            +
                          ensure
         
     | 
| 
      
 52 
     | 
    
         
            +
                            setup_added
         
     | 
| 
       55 
53 
     | 
    
         
             
                          end
         
     | 
| 
       56 
54 
     | 
    
         
             
                        end
         
     | 
| 
       57 
     | 
    
         
            -
                       
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                             
     | 
| 
      
 55 
     | 
    
         
            +
                      end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    when :teardown
         
     | 
| 
      
 57 
     | 
    
         
            +
                      unless method_defined?(:teardown_added)
         
     | 
| 
      
 58 
     | 
    
         
            +
                        alias_method :teardown_added, :teardown
         
     | 
| 
      
 59 
     | 
    
         
            +
                        define_method(:teardown) do
         
     | 
| 
      
 60 
     | 
    
         
            +
                          begin
         
     | 
| 
      
 61 
     | 
    
         
            +
                            teardown_added
         
     | 
| 
      
 62 
     | 
    
         
            +
                          ensure
         
     | 
| 
      
 63 
     | 
    
         
            +
                            teardown_new
         
     | 
| 
       66 
64 
     | 
    
         
             
                          end
         
     | 
| 
       67 
65 
     | 
    
         
             
                        end
         
     | 
| 
       68 
66 
     | 
    
         
             
                      end
         
     | 
| 
       69 
67 
     | 
    
         
             
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
       70 
69 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                      def setup_methods
         
     | 
| 
       74 
     | 
    
         
            -
                        @setup_methods ||= []
         
     | 
| 
       75 
     | 
    
         
            -
                      end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                      def teardown_methods
         
     | 
| 
       78 
     | 
    
         
            -
                        @teardown_methods ||= []
         
     | 
| 
       79 
     | 
    
         
            -
                      end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  class << self
         
     | 
| 
       80 
71 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
                    def setup_methods
         
     | 
| 
      
 73 
     | 
    
         
            +
                      @setup_methods ||= []
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end
         
     | 
| 
       84 
75 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
                    def teardown_methods
         
     | 
| 
      
 77 
     | 
    
         
            +
                      @teardown_methods ||= []
         
     | 
| 
      
 78 
     | 
    
         
            +
                    end
         
     | 
| 
       88 
79 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
                    def add_setup_method(symbol)
         
     | 
| 
      
 81 
     | 
    
         
            +
                      setup_methods << symbol
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
       90 
83 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                        child.instance_variable_set('@teardown_methods', teardown_methods.dup)
         
     | 
| 
       95 
     | 
    
         
            -
                      end
         
     | 
| 
      
 84 
     | 
    
         
            +
                    def add_teardown_method(symbol)
         
     | 
| 
      
 85 
     | 
    
         
            +
                      teardown_methods << symbol
         
     | 
| 
      
 86 
     | 
    
         
            +
                    end
         
     | 
| 
       96 
87 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                        alias_method :inherited_without_setup_and_teardown_methods, :inherited
         
     | 
| 
       99 
     | 
    
         
            -
                      end
         
     | 
| 
       100 
     | 
    
         
            -
                      alias_method :inherited, :inherited_with_setup_and_teardown_methods
         
     | 
| 
      
 88 
     | 
    
         
            +
                    private
         
     | 
| 
       101 
89 
     | 
    
         | 
| 
      
 90 
     | 
    
         
            +
                    def inherited_with_setup_and_teardown_methods(child)
         
     | 
| 
      
 91 
     | 
    
         
            +
                      inherited_without_setup_and_teardown_methods(child) if respond_to?(:inherited_without_setup_and_teardown_methods, true)
         
     | 
| 
      
 92 
     | 
    
         
            +
                      child.instance_variable_set('@setup_methods', setup_methods.dup)
         
     | 
| 
      
 93 
     | 
    
         
            +
                      child.instance_variable_set('@teardown_methods', teardown_methods.dup)
         
     | 
| 
       102 
94 
     | 
    
         
             
                    end
         
     | 
| 
       103 
95 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                     
     | 
| 
       105 
     | 
    
         
            -
                       
     | 
| 
      
 96 
     | 
    
         
            +
                    if respond_to?(:inherited, true)
         
     | 
| 
      
 97 
     | 
    
         
            +
                      alias_method :inherited_without_setup_and_teardown_methods, :inherited
         
     | 
| 
       106 
98 
     | 
    
         
             
                    end
         
     | 
| 
      
 99 
     | 
    
         
            +
                    alias_method :inherited, :inherited_with_setup_and_teardown_methods
         
     | 
| 
       107 
100 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                  def setup_mocha
         
     | 
| 
      
 104 
     | 
    
         
            +
                    self.class.class_eval { setup_methods }.each { |symbol| send(symbol) }
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                  def teardown_mocha
         
     | 
| 
      
 108 
     | 
    
         
            +
                    stored_exception = nil
         
     | 
| 
      
 109 
     | 
    
         
            +
                    self.class.class_eval { teardown_methods }.reverse.each do |symbol|
         
     | 
| 
      
 110 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 111 
     | 
    
         
            +
                        send(symbol)
         
     | 
| 
      
 112 
     | 
    
         
            +
                      rescue Exception => e
         
     | 
| 
      
 113 
     | 
    
         
            +
                        stored_exception ||= e
         
     | 
| 
       116 
114 
     | 
    
         
             
                      end
         
     | 
| 
       117 
     | 
    
         
            -
                      raise stored_exception if stored_exception
         
     | 
| 
       118 
115 
     | 
    
         
             
                    end
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
                    raise stored_exception if stored_exception
         
     | 
| 
       120 
117 
     | 
    
         
             
                  end
         
     | 
| 
       121 
118 
     | 
    
         | 
| 
       122 
119 
     | 
    
         
             
                end
         
     | 
| 
       123 
120 
     | 
    
         | 
| 
       124 
121 
     | 
    
         
             
              end
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/stubba.rb
    CHANGED
    
    
| 
         @@ -1,27 +1,25 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'stubba/central'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            module  
     | 
| 
       4 
     | 
    
         
            -
              module SetupAndTeardown
         
     | 
| 
      
 3 
     | 
    
         
            +
            module SetupAndTeardown
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
              def self.included(base)
         
     | 
| 
      
 6 
     | 
    
         
            +
                base.add_setup_method(:setup_stubs)
         
     | 
| 
      
 7 
     | 
    
         
            +
                base.add_teardown_method(:teardown_stubs)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
              def setup_stubs
         
     | 
| 
      
 11 
     | 
    
         
            +
                $stubba = Stubba::Central.new
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
              def teardown_stubs
         
     | 
| 
      
 15 
     | 
    
         
            +
                if $stubba then
         
     | 
| 
      
 16 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 17 
     | 
    
         
            +
                    $stubba.verify_all { add_assertion }
         
     | 
| 
      
 18 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 19 
     | 
    
         
            +
                    $stubba.unstub_all
         
     | 
| 
      
 20 
     | 
    
         
            +
                    $stubba = nil
         
     | 
| 
       23 
21 
     | 
    
         
             
                  end
         
     | 
| 
       24 
22 
     | 
    
         
             
                end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
23 
     | 
    
         
             
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -275,7 +275,6 @@ class ExpectationSimilarExpectationsTest < Test::Unit::TestCase 
     | 
|
| 
       275 
275 
     | 
    
         
             
                missing_expectation = MissingExpectation.new(:other_meth, @mock, [expectation]).with(1)
         
     | 
| 
       276 
276 
     | 
    
         
             
                exception = assert_raise(Test::Unit::AssertionFailedError) { missing_expectation.verify }
         
     | 
| 
       277 
277 
     | 
    
         
             
                assert_equal "Unexpected message :other_meth(1) sent to #{@mock.mocha_inspect}", exception.message
         
     | 
| 
       278 
     | 
    
         
            -
                p exception.message
         
     | 
| 
       279 
278 
     | 
    
         
             
              end
         
     | 
| 
       280 
279 
     | 
    
         | 
| 
       281 
280 
     | 
    
         
             
            end
         
     | 
| 
         @@ -94,7 +94,7 @@ class MochaTestResultIntegrationTest < Test::Unit::TestCase 
     | 
|
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
              def run_test(test_result = Test::Unit::TestResult.new, &block)
         
     | 
| 
       96 
96 
     | 
    
         
             
                test_class = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       97 
     | 
    
         
            -
                  include  
     | 
| 
      
 97 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       98 
98 
     | 
    
         
             
                  include Mocha::AutoVerify
         
     | 
| 
       99 
99 
     | 
    
         
             
                  define_method(:test_me, &block)
         
     | 
| 
       100 
100 
     | 
    
         
             
                end
         
     | 
| 
         @@ -7,7 +7,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       7 
7 
     | 
    
         
             
              def test_should_call_added_setup
         
     | 
| 
       8 
8 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       9 
9 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       10 
     | 
    
         
            -
                  include  
     | 
| 
      
 10 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       11 
11 
     | 
    
         
             
                  add_setup_method(:added_setup)
         
     | 
| 
       12 
12 
     | 
    
         
             
                  define_method(:added_setup) { methods_called << :added_setup }
         
     | 
| 
       13 
13 
     | 
    
         
             
                  define_method(:test_method) { methods_called << :test_method }
         
     | 
| 
         @@ -22,7 +22,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       22 
22 
     | 
    
         
             
              def test_should_call_added_teardown
         
     | 
| 
       23 
23 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       24 
24 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       25 
     | 
    
         
            -
                  include  
     | 
| 
      
 25 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       26 
26 
     | 
    
         
             
                  add_teardown_method(:added_teardown)
         
     | 
| 
       27 
27 
     | 
    
         
             
                  define_method(:added_teardown) { methods_called << :added_teardown }
         
     | 
| 
       28 
28 
     | 
    
         
             
                  define_method(:test_method) { methods_called << :test_method }
         
     | 
| 
         @@ -37,7 +37,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       37 
37 
     | 
    
         
             
              def test_should_call_both_added_teardowns_even_if_one_raises_exception
         
     | 
| 
       38 
38 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       39 
39 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       40 
     | 
    
         
            -
                  include  
     | 
| 
      
 40 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       41 
41 
     | 
    
         
             
                  add_teardown_method(:added_teardown_1)
         
     | 
| 
       42 
42 
     | 
    
         
             
                  add_teardown_method(:added_teardown_2)
         
     | 
| 
       43 
43 
     | 
    
         
             
                  define_method(:added_teardown_1) { methods_called << :added_teardown_1 }
         
     | 
| 
         @@ -55,7 +55,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       55 
55 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       56 
56 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       57 
57 
     | 
    
         
             
                  define_method(:setup) { methods_called << :setup }
         
     | 
| 
       58 
     | 
    
         
            -
                  include  
     | 
| 
      
 58 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       59 
59 
     | 
    
         
             
                  add_setup_method(:added_setup)
         
     | 
| 
       60 
60 
     | 
    
         
             
                  define_method(:added_setup) { methods_called << :added_setup }
         
     | 
| 
       61 
61 
     | 
    
         
             
                  define_method(:test_method) { methods_called << :test_method }
         
     | 
| 
         @@ -71,7 +71,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       71 
71 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       72 
72 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       73 
73 
     | 
    
         
             
                  define_method(:teardown) { methods_called << :teardown }
         
     | 
| 
       74 
     | 
    
         
            -
                  include  
     | 
| 
      
 74 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       75 
75 
     | 
    
         
             
                  add_teardown_method(:added_teardown)
         
     | 
| 
       76 
76 
     | 
    
         
             
                  define_method(:added_teardown) { methods_called << :added_teardown }
         
     | 
| 
       77 
77 
     | 
    
         
             
                  define_method(:test_method) { methods_called << :test_method }
         
     | 
| 
         @@ -86,7 +86,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       86 
86 
     | 
    
         
             
              def test_should_call_added_setup_and_setup_defined_after_module_included
         
     | 
| 
       87 
87 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       88 
88 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       89 
     | 
    
         
            -
                  include  
     | 
| 
      
 89 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       90 
90 
     | 
    
         
             
                  define_method(:setup) { methods_called << :setup }
         
     | 
| 
       91 
91 
     | 
    
         
             
                  add_setup_method(:added_setup)
         
     | 
| 
       92 
92 
     | 
    
         
             
                  define_method(:added_setup) { methods_called << :added_setup }
         
     | 
| 
         @@ -102,7 +102,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       102 
102 
     | 
    
         
             
              def test_should_call_added_teardown_and_teardown_defined_after_module_included
         
     | 
| 
       103 
103 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       104 
104 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       105 
     | 
    
         
            -
                  include  
     | 
| 
      
 105 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       106 
106 
     | 
    
         
             
                  define_method(:teardown) { methods_called << :teardown }
         
     | 
| 
       107 
107 
     | 
    
         
             
                  add_teardown_method(:added_teardown)
         
     | 
| 
       108 
108 
     | 
    
         
             
                  define_method(:added_teardown) { methods_called << :added_teardown }
         
     | 
| 
         @@ -118,7 +118,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       118 
118 
     | 
    
         
             
              def test_should_call_added_setup_and_setup_defined_in_derived_test_case
         
     | 
| 
       119 
119 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       120 
120 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       121 
     | 
    
         
            -
                  include  
     | 
| 
      
 121 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       122 
122 
     | 
    
         
             
                  add_setup_method(:added_setup)
         
     | 
| 
       123 
123 
     | 
    
         
             
                  define_method(:added_setup) { methods_called << :added_setup }
         
     | 
| 
       124 
124 
     | 
    
         
             
                end
         
     | 
| 
         @@ -136,7 +136,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       136 
136 
     | 
    
         
             
              def test_should_call_added_teardown_and_teardown_defined_in_derived_test_case
         
     | 
| 
       137 
137 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       138 
138 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       139 
     | 
    
         
            -
                  include  
     | 
| 
      
 139 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       140 
140 
     | 
    
         
             
                  add_teardown_method(:added_teardown)
         
     | 
| 
       141 
141 
     | 
    
         
             
                  define_method(:added_teardown) { methods_called << :added_teardown }
         
     | 
| 
       142 
142 
     | 
    
         
             
                end
         
     | 
| 
         @@ -155,7 +155,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       155 
155 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       156 
156 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       157 
157 
     | 
    
         
             
                  include ActiveRecordTestCase
         
     | 
| 
       158 
     | 
    
         
            -
                  include  
     | 
| 
      
 158 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       159 
159 
     | 
    
         
             
                  add_setup_method(:added_setup)
         
     | 
| 
       160 
160 
     | 
    
         
             
                  define_method(:added_setup) { methods_called << :added_setup }
         
     | 
| 
       161 
161 
     | 
    
         
             
                end
         
     | 
| 
         @@ -174,7 +174,7 @@ class MultipleSetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       174 
174 
     | 
    
         
             
                test_case = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       175 
175 
     | 
    
         
             
                  define_method(:methods_called) { @methods_called ||= [] }
         
     | 
| 
       176 
176 
     | 
    
         
             
                  include ActiveRecordTestCase
         
     | 
| 
       177 
     | 
    
         
            -
                  include  
     | 
| 
      
 177 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
       178 
178 
     | 
    
         
             
                  add_teardown_method(:added_teardown)
         
     | 
| 
       179 
179 
     | 
    
         
             
                  define_method(:added_teardown) { methods_called << :added_teardown }
         
     | 
| 
       180 
180 
     | 
    
         
             
                end
         
     | 
| 
         @@ -27,71 +27,20 @@ class InstanceMethodTest < Test::Unit::TestCase 
     | 
|
| 
       27 
27 
     | 
    
         
             
                klass = Class.new
         
     | 
| 
       28 
28 
     | 
    
         
             
                instance = klass.new
         
     | 
| 
       29 
29 
     | 
    
         
             
                method = InstanceMethod.new(instance, :non_existent_method)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       30 
31 
     | 
    
         
             
                assert_raise(Test::Unit::AssertionFailedError) { method.stub }
         
     | 
| 
       31 
32 
     | 
    
         
             
              end
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
              def  
     | 
| 
       34 
     | 
    
         
            -
                klass = Class.new { def method_x; end }
         
     | 
| 
       35 
     | 
    
         
            -
                instance = klass.new
         
     | 
| 
       36 
     | 
    
         
            -
                method = InstanceMethod.new(instance, :method_x)
         
     | 
| 
       37 
     | 
    
         
            -
                method.define_instance_accessor(:define_called)
         
     | 
| 
       38 
     | 
    
         
            -
                method.replace_instance_method(:define_new_method) { self.define_called = true }
         
     | 
| 
       39 
     | 
    
         
            -
                
         
     | 
| 
       40 
     | 
    
         
            -
                method.stub
         
     | 
| 
       41 
     | 
    
         
            -
                
         
     | 
| 
       42 
     | 
    
         
            -
                assert method.define_called
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
                
         
     | 
| 
       45 
     | 
    
         
            -
              def test_should_not_call_hide_original_method
         
     | 
| 
       46 
     | 
    
         
            -
                klass = Class.new { def method_x; end }
         
     | 
| 
       47 
     | 
    
         
            -
                instance = klass.new
         
     | 
| 
       48 
     | 
    
         
            -
                method = InstanceMethod.new(instance, :method_x)
         
     | 
| 
       49 
     | 
    
         
            -
                method.replace_instance_method(:define_new_method) { }
         
     | 
| 
       50 
     | 
    
         
            -
                method.define_instance_accessor(:hide_called)
         
     | 
| 
       51 
     | 
    
         
            -
                method.replace_instance_method(:hide_original_method) { self.hide_called = true }
         
     | 
| 
       52 
     | 
    
         
            -
                
         
     | 
| 
       53 
     | 
    
         
            -
                method.stub
         
     | 
| 
       54 
     | 
    
         
            -
                
         
     | 
| 
       55 
     | 
    
         
            -
                assert !method.hide_called
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
                
         
     | 
| 
       58 
     | 
    
         
            -
              def test_should_not_call_restore_original_method
         
     | 
| 
       59 
     | 
    
         
            -
                klass = Class.new { def method_x; end }
         
     | 
| 
       60 
     | 
    
         
            -
                instance = klass.new
         
     | 
| 
       61 
     | 
    
         
            -
                method = InstanceMethod.new(instance, :method_x)
         
     | 
| 
       62 
     | 
    
         
            -
                method.replace_instance_method(:define_new_method) { }
         
     | 
| 
       63 
     | 
    
         
            -
                method.define_instance_accessor(:restore_called)
         
     | 
| 
       64 
     | 
    
         
            -
                method.replace_instance_method(:restore_original_method) { self.restore_called = true }
         
     | 
| 
       65 
     | 
    
         
            -
                
         
     | 
| 
       66 
     | 
    
         
            -
                method.unstub
         
     | 
| 
       67 
     | 
    
         
            -
                
         
     | 
| 
       68 
     | 
    
         
            -
                assert !method.restore_called
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
              
         
     | 
| 
       71 
     | 
    
         
            -
              def test_should_not_call_remove_new_method
         
     | 
| 
      
 34 
     | 
    
         
            +
              def test_should_not_raise_assertion_failed_error_when_attempting_to_stub_existing_method
         
     | 
| 
       72 
35 
     | 
    
         
             
                klass = Class.new { def method_x; end }
         
     | 
| 
       73 
36 
     | 
    
         
             
                instance = klass.new
         
     | 
| 
       74 
37 
     | 
    
         
             
                method = InstanceMethod.new(instance, :method_x)
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                method. 
     | 
| 
       77 
     | 
    
         
            -
                method.replace_instance_method(:remove_new_method) { self.remove_called = true }
         
     | 
| 
       78 
     | 
    
         
            -
                
         
     | 
| 
       79 
     | 
    
         
            -
                method.unstub
         
     | 
| 
       80 
     | 
    
         
            -
                
         
     | 
| 
       81 
     | 
    
         
            -
                assert !method.remove_called
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                assert_nothing_raised(Test::Unit::AssertionFailedError) { method.stub }
         
     | 
| 
       82 
40 
     | 
    
         
             
              end
         
     | 
| 
       83 
41 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
              def  
     | 
| 
       85 
     | 
    
         
            -
                 
     | 
| 
       86 
     | 
    
         
            -
                instance = klass.new
         
     | 
| 
       87 
     | 
    
         
            -
                instance.define_instance_accessor(:reset_called)
         
     | 
| 
       88 
     | 
    
         
            -
                instance.define_instance_method(:reset_mocha) { self.reset_called = true }
         
     | 
| 
       89 
     | 
    
         
            -
                method = InstanceMethod.new(instance, :method_x)
         
     | 
| 
       90 
     | 
    
         
            -
                method.replace_instance_method(:define_new_method) { }
         
     | 
| 
       91 
     | 
    
         
            -
                
         
     | 
| 
       92 
     | 
    
         
            -
                method.unstub
         
     | 
| 
       93 
     | 
    
         
            -
                
         
     | 
| 
       94 
     | 
    
         
            -
                assert !instance.reset_called
         
     | 
| 
      
 42 
     | 
    
         
            +
              def test_should_inherit_from_class_method
         
     | 
| 
      
 43 
     | 
    
         
            +
                assert_equal ClassMethod, InstanceMethod.superclass
         
     | 
| 
       95 
44 
     | 
    
         
             
              end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       97 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -14,7 +14,7 @@ class SetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    define_method(:add_setup_method) { |symbol| @symbol = symbol }
         
     | 
| 
       15 
15 
     | 
    
         
             
                    define_method(:add_teardown_method) {}
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
     | 
    
         
            -
                  include  
     | 
| 
      
 17 
     | 
    
         
            +
                  include SetupAndTeardown
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                assert_equal :setup_stubs, test_case_class.symbol
         
     | 
| 
         @@ -27,7 +27,7 @@ class SetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    define_method(:add_setup_method) {}
         
     | 
| 
       28 
28 
     | 
    
         
             
                    define_method(:add_teardown_method) { |symbol| @symbol = symbol }
         
     | 
| 
       29 
29 
     | 
    
         
             
                  end
         
     | 
| 
       30 
     | 
    
         
            -
                  include  
     | 
| 
      
 30 
     | 
    
         
            +
                  include SetupAndTeardown
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                assert_equal :teardown_stubs, test_case_class.symbol
         
     | 
| 
         @@ -126,7 +126,7 @@ class SetupAndTeardownTest < Test::Unit::TestCase 
     | 
|
| 
       126 
126 
     | 
    
         
             
                  end
         
     | 
| 
       127 
127 
     | 
    
         
             
                  attr_accessor :add_assertion_called
         
     | 
| 
       128 
128 
     | 
    
         
             
                  define_method(:add_assertion) { self.add_assertion_called = true }
         
     | 
| 
       129 
     | 
    
         
            -
                  include  
     | 
| 
      
 129 
     | 
    
         
            +
                  include SetupAndTeardown
         
     | 
| 
       130 
130 
     | 
    
         
             
                end
         
     | 
| 
       131 
131 
     | 
    
         
             
              end
         
     | 
| 
       132 
132 
     | 
    
         | 
| 
         @@ -10,50 +10,87 @@ class StubbaIntegrationTest < Test::Unit::TestCase 
     | 
|
| 
       10 
10 
     | 
    
         
             
                def self.method_x
         
     | 
| 
       11 
11 
     | 
    
         
             
                  :original_return_value
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
                def instance_method_1
         
     | 
| 
      
 14 
     | 
    
         
            +
                  :original_return_value
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                # def self.object
         
     | 
| 
      
 17 
     | 
    
         
            +
                #   @object ||= Class.new do
         
     | 
| 
      
 18 
     | 
    
         
            +
                #     def instance_method_1
         
     | 
| 
      
 19 
     | 
    
         
            +
                #       :original_return_value
         
     | 
| 
      
 20 
     | 
    
         
            +
                #     end
         
     | 
| 
      
 21 
     | 
    
         
            +
                #   end.new
         
     | 
| 
      
 22 
     | 
    
         
            +
                # end
         
     | 
| 
       13 
23 
     | 
    
         
             
              end
         
     | 
| 
       14 
24 
     | 
    
         | 
| 
       15 
25 
     | 
    
         
             
              def test_should_stub_class_method_within_test
         
     | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
                  define_method(:test_me) do
         
     | 
| 
       20 
     | 
    
         
            -
                    DontMessWithMe.expects(:method_x).returns(:new_return_value)
         
     | 
| 
       21 
     | 
    
         
            -
                    assert_equal :new_return_value, DontMessWithMe.method_x
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 27 
     | 
    
         
            +
                  DontMessWithMe.expects(:method_x).returns(:new_return_value)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  assert_equal :new_return_value, DontMessWithMe.method_x
         
     | 
| 
       23 
29 
     | 
    
         
             
                end
         
     | 
| 
       24 
     | 
    
         
            -
                test = test_class.new(:test_me)
         
     | 
| 
       25 
30 
     | 
    
         | 
| 
       26 
31 
     | 
    
         
             
                test_result = Test::Unit::TestResult.new
         
     | 
| 
       27 
32 
     | 
    
         
             
                test.run(test_result) {}
         
     | 
| 
       28 
33 
     | 
    
         
             
                assert test_result.passed?
         
     | 
| 
       29 
34 
     | 
    
         
             
              end
         
     | 
| 
       30 
35 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              def  
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
       34 
     | 
    
         
            -
                  include Stubba::SetupAndTeardown
         
     | 
| 
       35 
     | 
    
         
            -
                  define_method(:test_me) do
         
     | 
| 
       36 
     | 
    
         
            -
                    DontMessWithMe.expects(:method_x).returns(:new_return_value)
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
              def test_should_leave_stubbed_class_method_unchanged_after_test
         
     | 
| 
      
 37 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 38 
     | 
    
         
            +
                  DontMessWithMe.expects(:method_x).returns(:new_return_value)
         
     | 
| 
       38 
39 
     | 
    
         
             
                end
         
     | 
| 
       39 
     | 
    
         
            -
                test = test_class.new(:test_me)
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                test.run(Test::Unit::TestResult.new) {}
         
     | 
| 
       42 
42 
     | 
    
         
             
                assert_equal :original_return_value, DontMessWithMe.method_x
         
     | 
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
              def  
     | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
       48 
     | 
    
         
            -
                  include Stubba::SetupAndTeardown
         
     | 
| 
       49 
     | 
    
         
            -
                  define_method(:test_me) do
         
     | 
| 
       50 
     | 
    
         
            -
                    DontMessWithMe.expects(:method_x)
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
              def test_should_reset_class_expectations_after_test
         
     | 
| 
      
 46 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  DontMessWithMe.expects(:method_x)
         
     | 
| 
       52 
48 
     | 
    
         
             
                end
         
     | 
| 
       53 
     | 
    
         
            -
                test = test_class.new(:test_me)
         
     | 
| 
       54 
49 
     | 
    
         | 
| 
       55 
50 
     | 
    
         
             
                test.run(Test::Unit::TestResult.new) {}
         
     | 
| 
       56 
51 
     | 
    
         
             
                assert_equal 0, DontMessWithMe.mocha.expectations.size
         
     | 
| 
       57 
52 
     | 
    
         
             
              end  
         
     | 
| 
       58 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
              def test_should_stub_instance_method_within_test
         
     | 
| 
      
 55 
     | 
    
         
            +
                instance = DontMessWithMe.new
         
     | 
| 
      
 56 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 57 
     | 
    
         
            +
                  instance.expects(:instance_method_1).returns(:new_return_value)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  assert_equal :new_return_value, instance.instance_method_1
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
                test_result = Test::Unit::TestResult.new
         
     | 
| 
      
 61 
     | 
    
         
            +
                test.run(test_result) {}
         
     | 
| 
      
 62 
     | 
    
         
            +
                assert test_result.passed?
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
              
         
     | 
| 
      
 65 
     | 
    
         
            +
              def test_should_leave_stubbed_instance_method_unchanged_after_test
         
     | 
| 
      
 66 
     | 
    
         
            +
                instance = DontMessWithMe.new
         
     | 
| 
      
 67 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 68 
     | 
    
         
            +
                  instance.expects(:instance_method_1).returns(:new_return_value)
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                test.run(Test::Unit::TestResult.new) {}
         
     | 
| 
      
 72 
     | 
    
         
            +
                assert_equal :original_return_value, instance.instance_method_1
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
              
         
     | 
| 
      
 75 
     | 
    
         
            +
              def test_should_reset_instance_expectations_after_test
         
     | 
| 
      
 76 
     | 
    
         
            +
                instance = DontMessWithMe.new
         
     | 
| 
      
 77 
     | 
    
         
            +
                test = build_test do
         
     | 
| 
      
 78 
     | 
    
         
            +
                  instance.expects(:instance_method_1).returns(:new_return_value)
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
                test.run(Test::Unit::TestResult.new) {}
         
     | 
| 
      
 82 
     | 
    
         
            +
                assert_equal 0, instance.mocha.expectations.size
         
     | 
| 
      
 83 
     | 
    
         
            +
              end  
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              private
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              def build_test(&block)
         
     | 
| 
      
 88 
     | 
    
         
            +
                test_class = Class.new(Test::Unit::TestCase) do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
      
 90 
     | 
    
         
            +
                  include SetupAndTeardown
         
     | 
| 
      
 91 
     | 
    
         
            +
                  define_method(:test_me, &block)
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
                test_class.new(:test_me)
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       59 
96 
     | 
    
         
             
            end
         
     | 
| 
         @@ -74,8 +74,8 @@ class StubbaTestResultIntegrationTest < Test::Unit::TestCase 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
              def run_test(test_result = Test::Unit::TestResult.new, &block)
         
     | 
| 
       76 
76 
     | 
    
         
             
                test_class = Class.new(Test::Unit::TestCase) do
         
     | 
| 
       77 
     | 
    
         
            -
                  include  
     | 
| 
       78 
     | 
    
         
            -
                  include  
     | 
| 
      
 77 
     | 
    
         
            +
                  include MultipleSetupAndTeardown
         
     | 
| 
      
 78 
     | 
    
         
            +
                  include SetupAndTeardown
         
     | 
| 
       79 
79 
     | 
    
         
             
                  define_method(:test_me, &block)
         
     | 
| 
       80 
80 
     | 
    
         
             
                end
         
     | 
| 
       81 
81 
     | 
    
         
             
                test = test_class.new(:test_me)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ rubygems_version: 0.8.11 
     | 
|
| 
       3 
3 
     | 
    
         
             
            specification_version: 1
         
     | 
| 
       4 
4 
     | 
    
         
             
            name: mocha
         
     | 
| 
       5 
5 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
       7 
     | 
    
         
            -
            date:  
     | 
| 
      
 6 
     | 
    
         
            +
              version: 0.3.3
         
     | 
| 
      
 7 
     | 
    
         
            +
            date: 2007-01-18 00:00:00 +00:00
         
     | 
| 
       8 
8 
     | 
    
         
             
            summary: Mocking and stubbing library
         
     | 
| 
       9 
9 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       10 
10 
     | 
    
         
             
              - lib
         
     |