bourne 1.1.1 → 1.1.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/README.md +1 -1
- data/bourne.gemspec +1 -1
- data/lib/bourne/api.rb +15 -1
- data/lib/bourne/version.rb +1 -1
- data/test/acceptance/acceptance_test_helper.rb +9 -9
- data/test/acceptance/mocha_example_test.rb +26 -26
- data/test/acceptance/spy_test.rb +10 -4
- data/test/acceptance/stubba_example_test.rb +24 -24
- data/test/execution_point.rb +7 -7
- data/test/method_definer.rb +2 -2
- data/test/mini_test_result.rb +16 -16
- data/test/simple_counter.rb +5 -5
- data/test/test_runner.rb +3 -3
- data/test/unit/expectation_test.rb +65 -65
- data/test/unit/mock_test.rb +44 -44
- data/test/unit/mockery_test.rb +24 -24
- metadata +18 -19
- data/Gemfile.lock +0 -20
    
        data/README.md
    CHANGED
    
    
    
        data/bourne.gemspec
    CHANGED
    
    | @@ -20,7 +20,7 @@ Gem::Specification.new do |s| | |
| 20 20 | 
             
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 21 21 | 
             
              s.require_paths = ["lib"]
         | 
| 22 22 |  | 
| 23 | 
            -
              s.add_dependency('mocha', '= 0.10. | 
| 23 | 
            +
              s.add_dependency('mocha', '= 0.10.5')
         | 
| 24 24 |  | 
| 25 25 | 
             
              s.add_development_dependency('rake')
         | 
| 26 26 | 
             
            end
         | 
    
        data/lib/bourne/api.rb
    CHANGED
    
    | @@ -51,7 +51,11 @@ module Mocha # :nodoc: | |
| 51 51 | 
             
                  end
         | 
| 52 52 |  | 
| 53 53 | 
             
                  def failure_message
         | 
| 54 | 
            -
                     | 
| 54 | 
            +
                    message  = ""
         | 
| 55 | 
            +
                    if matching_stubs.empty?
         | 
| 56 | 
            +
                      message << "unstubbed, "
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                    message << @expectation.mocha_inspect
         | 
| 55 59 | 
             
                  end
         | 
| 56 60 |  | 
| 57 61 | 
             
                  private
         | 
| @@ -71,6 +75,16 @@ module Mocha # :nodoc: | |
| 71 75 | 
             
                      invocation.mock.equal?(@mock)
         | 
| 72 76 | 
             
                    end
         | 
| 73 77 | 
             
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  def matching_stubs
         | 
| 80 | 
            +
                    Mockery.instance.stubba.stubba_methods.select do |method|
         | 
| 81 | 
            +
                      matching_stub?(method)
         | 
| 82 | 
            +
                    end
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  def matching_stub?(method)
         | 
| 86 | 
            +
                    method.mock.equal?(@mock) && method.method == @expected_method_name
         | 
| 87 | 
            +
                  end
         | 
| 74 88 | 
             
                end
         | 
| 75 89 |  | 
| 76 90 | 
             
                # :call-seq:
         | 
    
        data/lib/bourne/version.rb
    CHANGED
    
    
| @@ -3,25 +3,25 @@ require 'test_runner' | |
| 3 3 | 
             
            require 'mocha/configuration'
         | 
| 4 4 |  | 
| 5 5 | 
             
            module AcceptanceTest
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 7 | 
             
              class FakeLogger
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                attr_reader :warnings
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
                def initialize
         | 
| 12 12 | 
             
                  @warnings = []
         | 
| 13 13 | 
             
                end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
                def warn(message)
         | 
| 16 16 | 
             
                  @warnings << message
         | 
| 17 17 | 
             
                end
         | 
| 18 | 
            -
             | 
| 18 | 
            +
             | 
| 19 19 | 
             
              end
         | 
| 20 | 
            -
             | 
| 20 | 
            +
             | 
| 21 21 | 
             
              attr_reader :logger
         | 
| 22 22 |  | 
| 23 23 | 
             
              include TestRunner
         | 
| 24 | 
            -
             | 
| 24 | 
            +
             | 
| 25 25 | 
             
              def setup_acceptance_test
         | 
| 26 26 | 
             
                Mocha::Configuration.reset_configuration
         | 
| 27 27 | 
             
                @logger = FakeLogger.new
         | 
| @@ -29,10 +29,10 @@ module AcceptanceTest | |
| 29 29 | 
             
                @original_logger = mockery.logger
         | 
| 30 30 | 
             
                mockery.logger = @logger
         | 
| 31 31 | 
             
              end
         | 
| 32 | 
            -
             | 
| 32 | 
            +
             | 
| 33 33 | 
             
              def teardown_acceptance_test
         | 
| 34 34 | 
             
                Mocha::Configuration.reset_configuration
         | 
| 35 35 | 
             
                Mocha::Mockery.instance.logger = @original_logger
         | 
| 36 36 | 
             
              end
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
            end
         | 
| @@ -2,97 +2,97 @@ require File.expand_path('../../test_helper', __FILE__) | |
| 2 2 | 
             
            require 'mocha'
         | 
| 3 3 |  | 
| 4 4 | 
             
            class MochaExampleTest < Test::Unit::TestCase
         | 
| 5 | 
            -
             | 
| 5 | 
            +
             | 
| 6 6 | 
             
              class Rover
         | 
| 7 | 
            -
             | 
| 7 | 
            +
             | 
| 8 8 | 
             
                def initialize(left_track, right_track, steps_per_metre, steps_per_degree)
         | 
| 9 9 | 
             
                  @left_track, @right_track, @steps_per_metre, @steps_per_degree = left_track, right_track, steps_per_metre, steps_per_degree
         | 
| 10 10 | 
             
                end
         | 
| 11 | 
            -
             | 
| 11 | 
            +
             | 
| 12 12 | 
             
                def forward(metres)
         | 
| 13 13 | 
             
                  @left_track.step(metres * @steps_per_metre)
         | 
| 14 14 | 
             
                  @right_track.step(metres * @steps_per_metre)
         | 
| 15 15 | 
             
                  wait
         | 
| 16 16 | 
             
                end
         | 
| 17 | 
            -
             | 
| 17 | 
            +
             | 
| 18 18 | 
             
                def backward(metres)
         | 
| 19 19 | 
             
                  forward(-metres)
         | 
| 20 20 | 
             
                end
         | 
| 21 | 
            -
             | 
| 21 | 
            +
             | 
| 22 22 | 
             
                def left(degrees)
         | 
| 23 23 | 
             
                  @left_track.step(-degrees * @steps_per_degree)
         | 
| 24 24 | 
             
                  @right_track.step(+degrees * @steps_per_degree)
         | 
| 25 25 | 
             
                  wait
         | 
| 26 26 | 
             
                end
         | 
| 27 | 
            -
             | 
| 27 | 
            +
             | 
| 28 28 | 
             
                def right(degrees)
         | 
| 29 29 | 
             
                  left(-degrees)
         | 
| 30 30 | 
             
                end
         | 
| 31 | 
            -
             | 
| 31 | 
            +
             | 
| 32 32 | 
             
                def wait
         | 
| 33 33 | 
             
                  while (@left_track.moving? or @right_track.moving?); end
         | 
| 34 34 | 
             
                end
         | 
| 35 | 
            -
             | 
| 35 | 
            +
             | 
| 36 36 | 
             
              end
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
              def test_should_step_both_tracks_forward_ten_steps
         | 
| 39 39 | 
             
                left_track = mock('left_track')
         | 
| 40 40 | 
             
                right_track = mock('right_track')
         | 
| 41 41 | 
             
                steps_per_metre = 5
         | 
| 42 42 | 
             
                rover = Rover.new(left_track, right_track, steps_per_metre, nil)
         | 
| 43 | 
            -
             | 
| 43 | 
            +
             | 
| 44 44 | 
             
                left_track.expects(:step).with(10)
         | 
| 45 45 | 
             
                right_track.expects(:step).with(10)
         | 
| 46 | 
            -
             | 
| 46 | 
            +
             | 
| 47 47 | 
             
                left_track.stubs(:moving?).returns(false)
         | 
| 48 48 | 
             
                right_track.stubs(:moving?).returns(false)
         | 
| 49 | 
            -
             | 
| 49 | 
            +
             | 
| 50 50 | 
             
                rover.forward(2)
         | 
| 51 51 | 
             
              end
         | 
| 52 | 
            -
             | 
| 52 | 
            +
             | 
| 53 53 | 
             
              def test_should_step_both_tracks_backward_ten_steps
         | 
| 54 54 | 
             
                left_track = mock('left_track')
         | 
| 55 55 | 
             
                right_track = mock('right_track')
         | 
| 56 56 | 
             
                steps_per_metre = 5
         | 
| 57 57 | 
             
                rover = Rover.new(left_track, right_track, steps_per_metre, nil)
         | 
| 58 | 
            -
             | 
| 58 | 
            +
             | 
| 59 59 | 
             
                left_track.expects(:step).with(-10)
         | 
| 60 60 | 
             
                right_track.expects(:step).with(-10)
         | 
| 61 | 
            -
             | 
| 61 | 
            +
             | 
| 62 62 | 
             
                left_track.stubs(:moving?).returns(false)
         | 
| 63 63 | 
             
                right_track.stubs(:moving?).returns(false)
         | 
| 64 | 
            -
             | 
| 64 | 
            +
             | 
| 65 65 | 
             
                rover.backward(2)
         | 
| 66 66 | 
             
              end
         | 
| 67 | 
            -
             | 
| 67 | 
            +
             | 
| 68 68 | 
             
              def test_should_step_left_track_forwards_five_steps_and_right_track_backwards_five_steps
         | 
| 69 69 | 
             
                left_track = mock('left_track')
         | 
| 70 70 | 
             
                right_track = mock('right_track')
         | 
| 71 71 | 
             
                steps_per_degree = 5.0 / 90.0
         | 
| 72 72 | 
             
                rover = Rover.new(left_track, right_track, nil, steps_per_degree)
         | 
| 73 | 
            -
             | 
| 73 | 
            +
             | 
| 74 74 | 
             
                left_track.expects(:step).with(+5)
         | 
| 75 75 | 
             
                right_track.expects(:step).with(-5)
         | 
| 76 | 
            -
             | 
| 76 | 
            +
             | 
| 77 77 | 
             
                left_track.stubs(:moving?).returns(false)
         | 
| 78 78 | 
             
                right_track.stubs(:moving?).returns(false)
         | 
| 79 | 
            -
             | 
| 79 | 
            +
             | 
| 80 80 | 
             
                rover.right(90)
         | 
| 81 81 | 
             
              end
         | 
| 82 | 
            -
             | 
| 82 | 
            +
             | 
| 83 83 | 
             
              def test_should_step_left_track_backwards_five_steps_and_right_track_forwards_five_steps
         | 
| 84 84 | 
             
                left_track = mock('left_track')
         | 
| 85 85 | 
             
                right_track = mock('right_track')
         | 
| 86 86 | 
             
                steps_per_degree = 5.0 / 90.0
         | 
| 87 87 | 
             
                rover = Rover.new(left_track, right_track, nil, steps_per_degree)
         | 
| 88 | 
            -
             | 
| 88 | 
            +
             | 
| 89 89 | 
             
                left_track.expects(:step).with(-5)
         | 
| 90 90 | 
             
                right_track.expects(:step).with(+5)
         | 
| 91 | 
            -
             | 
| 91 | 
            +
             | 
| 92 92 | 
             
                left_track.stubs(:moving?).returns(false)
         | 
| 93 93 | 
             
                right_track.stubs(:moving?).returns(false)
         | 
| 94 | 
            -
             | 
| 94 | 
            +
             | 
| 95 95 | 
             
                rover.left(90)
         | 
| 96 96 | 
             
              end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
            end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            end
         | 
    
        data/test/acceptance/spy_test.rb
    CHANGED
    
    | @@ -7,11 +7,11 @@ module SpyTestMethods | |
| 7 7 | 
             
              def setup
         | 
| 8 8 | 
             
                setup_acceptance_test
         | 
| 9 9 | 
             
              end
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
              def teardown
         | 
| 12 12 | 
             
                teardown_acceptance_test
         | 
| 13 13 | 
             
              end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
              def test_should_accept_wildcard_stub_call_without_arguments
         | 
| 16 16 | 
             
                instance = new_instance
         | 
| 17 17 | 
             
                instance.stubs(:magic)
         | 
| @@ -95,6 +95,12 @@ module SpyTestMethods | |
| 95 95 | 
             
                flunk("Expected to fail")
         | 
| 96 96 | 
             
              end
         | 
| 97 97 |  | 
| 98 | 
            +
              def test_should_warn_for_unstubbed_methods_with_expectations
         | 
| 99 | 
            +
                new_instance.stubs(:unknown)
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                assert_fails(/unstubbed, expected exactly once/) { assert_matcher_accepts have_received(:unknown), new_instance }
         | 
| 102 | 
            +
              end
         | 
| 103 | 
            +
             | 
| 98 104 | 
             
              def test_should_reject_not_enough_calls
         | 
| 99 105 | 
             
                instance = new_instance
         | 
| 100 106 | 
             
                instance.stubs(:magic)
         | 
| @@ -148,10 +154,10 @@ class StubEverythingSpyTest < Test::Unit::TestCase | |
| 148 154 | 
             
              def setup
         | 
| 149 155 | 
             
                setup_acceptance_test
         | 
| 150 156 | 
             
              end
         | 
| 151 | 
            -
             | 
| 157 | 
            +
             | 
| 152 158 | 
             
              def teardown
         | 
| 153 159 | 
             
                teardown_acceptance_test
         | 
| 154 | 
            -
              end | 
| 160 | 
            +
              end
         | 
| 155 161 | 
             
              def test_should_match_invocations_with_no_explicit_stubbing
         | 
| 156 162 | 
             
                instance = stub_everything
         | 
| 157 163 | 
             
                instance.surprise!
         | 
| @@ -2,86 +2,86 @@ require File.expand_path('../../test_helper', __FILE__) | |
| 2 2 | 
             
            require 'mocha'
         | 
| 3 3 |  | 
| 4 4 | 
             
            class Widget
         | 
| 5 | 
            -
             | 
| 5 | 
            +
             | 
| 6 6 | 
             
              def model
         | 
| 7 7 | 
             
                'original_model'
         | 
| 8 8 | 
             
              end
         | 
| 9 | 
            -
             | 
| 9 | 
            +
             | 
| 10 10 | 
             
              class << self
         | 
| 11 | 
            -
             | 
| 11 | 
            +
             | 
| 12 12 | 
             
                def find(options)
         | 
| 13 13 | 
             
                  []
         | 
| 14 14 | 
             
                end
         | 
| 15 | 
            -
             | 
| 15 | 
            +
             | 
| 16 16 | 
             
                def create(attributes)
         | 
| 17 17 | 
             
                  Widget.new
         | 
| 18 18 | 
             
                end
         | 
| 19 | 
            -
             | 
| 19 | 
            +
             | 
| 20 20 | 
             
              end
         | 
| 21 | 
            -
             | 
| 21 | 
            +
             | 
| 22 22 | 
             
            end
         | 
| 23 23 |  | 
| 24 24 | 
             
            module Thingy
         | 
| 25 | 
            -
             | 
| 25 | 
            +
             | 
| 26 26 | 
             
              def self.wotsit
         | 
| 27 27 | 
             
                :hoojamaflip
         | 
| 28 28 | 
             
              end
         | 
| 29 | 
            -
             | 
| 29 | 
            +
             | 
| 30 30 | 
             
            end
         | 
| 31 31 |  | 
| 32 32 | 
             
            class StubbaExampleTest < Test::Unit::TestCase
         | 
| 33 | 
            -
             | 
| 33 | 
            +
             | 
| 34 34 | 
             
              def test_should_stub_instance_method
         | 
| 35 35 | 
             
                widget = Widget.new
         | 
| 36 36 | 
             
                widget.expects(:model).returns('different_model')
         | 
| 37 37 | 
             
                assert_equal 'different_model', widget.model
         | 
| 38 38 | 
             
              end
         | 
| 39 | 
            -
             | 
| 39 | 
            +
             | 
| 40 40 | 
             
              def test_should_stub_module_method
         | 
| 41 41 | 
             
                should_stub_module_method
         | 
| 42 42 | 
             
              end
         | 
| 43 | 
            -
             | 
| 43 | 
            +
             | 
| 44 44 | 
             
              def test_should_stub_module_method_again
         | 
| 45 45 | 
             
                should_stub_module_method
         | 
| 46 46 | 
             
              end
         | 
| 47 | 
            -
             | 
| 47 | 
            +
             | 
| 48 48 | 
             
              def test_should_stub_class_method
         | 
| 49 49 | 
             
                should_stub_class_method
         | 
| 50 50 | 
             
              end
         | 
| 51 | 
            -
             | 
| 51 | 
            +
             | 
| 52 52 | 
             
              def test_should_stub_class_method_again
         | 
| 53 53 | 
             
                should_stub_class_method
         | 
| 54 54 | 
             
              end
         | 
| 55 | 
            -
             | 
| 55 | 
            +
             | 
| 56 56 | 
             
              def test_should_stub_instance_method_on_any_instance_of_a_class
         | 
| 57 57 | 
             
                should_stub_instance_method_on_any_instance_of_a_class
         | 
| 58 58 | 
             
              end
         | 
| 59 | 
            -
             | 
| 59 | 
            +
             | 
| 60 60 | 
             
              def test_should_stub_instance_method_on_any_instance_of_a_class_again
         | 
| 61 61 | 
             
                should_stub_instance_method_on_any_instance_of_a_class
         | 
| 62 62 | 
             
              end
         | 
| 63 | 
            -
             | 
| 63 | 
            +
             | 
| 64 64 | 
             
              def test_should_stub_two_different_class_methods
         | 
| 65 65 | 
             
                should_stub_two_different_class_methods
         | 
| 66 66 | 
             
              end
         | 
| 67 | 
            -
             | 
| 67 | 
            +
             | 
| 68 68 | 
             
              def test_should_stub_two_different_class_methods_again
         | 
| 69 69 | 
             
                should_stub_two_different_class_methods
         | 
| 70 70 | 
             
              end
         | 
| 71 | 
            -
             | 
| 71 | 
            +
             | 
| 72 72 | 
             
              private
         | 
| 73 | 
            -
             | 
| 73 | 
            +
             | 
| 74 74 | 
             
              def should_stub_module_method
         | 
| 75 75 | 
             
                Thingy.expects(:wotsit).returns(:dooda)
         | 
| 76 76 | 
             
                assert_equal :dooda, Thingy.wotsit
         | 
| 77 77 | 
             
              end
         | 
| 78 | 
            -
             | 
| 78 | 
            +
             | 
| 79 79 | 
             
              def should_stub_class_method
         | 
| 80 80 | 
             
                widgets = [Widget.new]
         | 
| 81 81 | 
             
                Widget.expects(:find).with(:all).returns(widgets)
         | 
| 82 82 | 
             
                assert_equal widgets, Widget.find(:all)
         | 
| 83 | 
            -
              end | 
| 84 | 
            -
             | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 85 | 
             
              def should_stub_two_different_class_methods
         | 
| 86 86 | 
             
                found_widgets = [Widget.new]
         | 
| 87 87 | 
             
                created_widget = Widget.new
         | 
| @@ -90,7 +90,7 @@ class StubbaExampleTest < Test::Unit::TestCase | |
| 90 90 | 
             
                assert_equal found_widgets, Widget.find(:all)
         | 
| 91 91 | 
             
                assert_equal created_widget, Widget.create(:model => 'wombat')
         | 
| 92 92 | 
             
              end
         | 
| 93 | 
            -
             | 
| 93 | 
            +
             | 
| 94 94 | 
             
              def should_stub_instance_method_on_any_instance_of_a_class
         | 
| 95 95 | 
             
                Widget.any_instance.expects(:model).at_least_once.returns('another_model')
         | 
| 96 96 | 
             
                widget_1 = Widget.new
         | 
| @@ -99,4 +99,4 @@ class StubbaExampleTest < Test::Unit::TestCase | |
| 99 99 | 
             
                assert_equal 'another_model', widget_2.model
         | 
| 100 100 | 
             
              end
         | 
| 101 101 |  | 
| 102 | 
            -
            end
         | 
| 102 | 
            +
            end
         | 
    
        data/test/execution_point.rb
    CHANGED
    
    | @@ -1,20 +1,20 @@ | |
| 1 1 | 
             
            class ExecutionPoint
         | 
| 2 | 
            -
             | 
| 2 | 
            +
             | 
| 3 3 | 
             
              attr_reader :backtrace
         | 
| 4 4 |  | 
| 5 5 | 
             
              def self.current
         | 
| 6 6 | 
             
                new(caller)
         | 
| 7 7 | 
             
              end
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
              def initialize(backtrace)
         | 
| 10 10 | 
             
                @backtrace = backtrace
         | 
| 11 11 | 
             
              end
         | 
| 12 | 
            -
             | 
| 12 | 
            +
             | 
| 13 13 | 
             
              def file_name
         | 
| 14 14 | 
             
                return "unknown" unless @backtrace && @backtrace.first
         | 
| 15 15 | 
             
                /\A(.*?):\d+/.match(@backtrace.first)[1]
         | 
| 16 16 | 
             
              end
         | 
| 17 | 
            -
             | 
| 17 | 
            +
             | 
| 18 18 | 
             
              def line_number
         | 
| 19 19 | 
             
                return "unknown" unless @backtrace && @backtrace.first
         | 
| 20 20 | 
             
                Integer(/\A.*?:(\d+)/.match(@backtrace.first)[1])
         | 
| @@ -24,13 +24,13 @@ class ExecutionPoint | |
| 24 24 | 
             
                return false unless other.is_a?(ExecutionPoint)
         | 
| 25 25 | 
             
                (file_name == other.file_name) and (line_number == other.line_number)
         | 
| 26 26 | 
             
              end
         | 
| 27 | 
            -
             | 
| 27 | 
            +
             | 
| 28 28 | 
             
              def to_s
         | 
| 29 29 | 
             
                "file: #{file_name}; line: #{line_number}"
         | 
| 30 30 | 
             
              end
         | 
| 31 | 
            -
             | 
| 31 | 
            +
             | 
| 32 32 | 
             
              def inspect
         | 
| 33 33 | 
             
                to_s
         | 
| 34 34 | 
             
              end
         | 
| 35 | 
            -
             | 
| 35 | 
            +
             | 
| 36 36 | 
             
            end
         | 
    
        data/test/method_definer.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require 'metaclass'
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Mocha
         | 
| 4 | 
            -
             | 
| 4 | 
            +
             | 
| 5 5 | 
             
              module ObjectMethods
         | 
| 6 6 | 
             
                def define_instance_method(method_symbol, &block)
         | 
| 7 7 | 
             
                  __metaclass__.send(:define_method, method_symbol, block)
         | 
| @@ -16,7 +16,7 @@ module Mocha | |
| 16 16 | 
             
                  symbols.each { |symbol| __metaclass__.send(:attr_accessor, symbol) }
         | 
| 17 17 | 
             
                end
         | 
| 18 18 | 
             
              end
         | 
| 19 | 
            -
             | 
| 19 | 
            +
             | 
| 20 20 | 
             
            end
         | 
| 21 21 |  | 
| 22 22 | 
             
            class Object
         | 
    
        data/test/mini_test_result.rb
    CHANGED
    
    | @@ -3,30 +3,30 @@ require 'test/unit/testcase' | |
| 3 3 | 
             
            require 'minitest/unit'
         | 
| 4 4 |  | 
| 5 5 | 
             
            class MiniTestResult
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 7 | 
             
              FAILURE_PATTERN = %r{(Failure)\:\n([^\(]+)\(([^\)]+)\) \[([^\]]+)\]\:\n(.*)\n}m
         | 
| 8 8 | 
             
              ERROR_PATTERN   = %r{(Error)\:\n([^\(]+)\(([^\)]+)\)\:\n(.+?)\n}m
         | 
| 9 | 
            -
             | 
| 9 | 
            +
             | 
| 10 10 | 
             
              def self.parse_failure(raw)
         | 
| 11 11 | 
             
                matches = FAILURE_PATTERN.match(raw)
         | 
| 12 12 | 
             
                return nil unless matches
         | 
| 13 13 | 
             
                Failure.new(matches[2], matches[3], [matches[4]], matches[5])
         | 
| 14 14 | 
             
              end
         | 
| 15 | 
            -
             | 
| 15 | 
            +
             | 
| 16 16 | 
             
              def self.parse_error(raw)
         | 
| 17 17 | 
             
                matches = ERROR_PATTERN.match(raw)
         | 
| 18 18 | 
             
                return nil unless matches
         | 
| 19 19 | 
             
                backtrace = raw.gsub(ERROR_PATTERN, '').split("\n").map(&:strip)
         | 
| 20 20 | 
             
                Error.new(matches[2], matches[3], matches[4], backtrace)
         | 
| 21 21 | 
             
              end
         | 
| 22 | 
            -
             | 
| 22 | 
            +
             | 
| 23 23 | 
             
              class Failure
         | 
| 24 24 | 
             
                attr_reader :method, :test_case, :location, :message
         | 
| 25 25 | 
             
                def initialize(method, test_case, location, message)
         | 
| 26 26 | 
             
                  @method, @test_case, @location, @message = method, test_case, location, message
         | 
| 27 27 | 
             
                end
         | 
| 28 28 | 
             
              end
         | 
| 29 | 
            -
             | 
| 29 | 
            +
             | 
| 30 30 | 
             
              class Error
         | 
| 31 31 | 
             
                class Exception
         | 
| 32 32 | 
             
                  attr_reader :message, :backtrace
         | 
| @@ -34,49 +34,49 @@ class MiniTestResult | |
| 34 34 | 
             
                    @message, @backtrace = message, location
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 | 
             
                end
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
                attr_reader :method, :test_case, :exception
         | 
| 39 39 | 
             
                def initialize(method, test_case, message, backtrace)
         | 
| 40 40 | 
             
                  @method, @test_case, @exception = method, test_case, Exception.new(message, backtrace)
         | 
| 41 41 | 
             
                end
         | 
| 42 42 | 
             
              end
         | 
| 43 | 
            -
             | 
| 43 | 
            +
             | 
| 44 44 | 
             
              def initialize(runner, test)
         | 
| 45 45 | 
             
                @runner, @test = runner, test
         | 
| 46 46 | 
             
              end
         | 
| 47 | 
            -
             | 
| 47 | 
            +
             | 
| 48 48 | 
             
              def failure_count
         | 
| 49 49 | 
             
                @runner.failures
         | 
| 50 50 | 
             
              end
         | 
| 51 | 
            -
             | 
| 51 | 
            +
             | 
| 52 52 | 
             
              def assertion_count
         | 
| 53 53 | 
             
                @test._assertions
         | 
| 54 54 | 
             
              end
         | 
| 55 | 
            -
             | 
| 55 | 
            +
             | 
| 56 56 | 
             
              def error_count
         | 
| 57 57 | 
             
                @runner.errors
         | 
| 58 58 | 
             
              end
         | 
| 59 | 
            -
             | 
| 59 | 
            +
             | 
| 60 60 | 
             
              def passed?
         | 
| 61 61 | 
             
                @test.passed?
         | 
| 62 62 | 
             
              end
         | 
| 63 | 
            -
             | 
| 63 | 
            +
             | 
| 64 64 | 
             
              def failures
         | 
| 65 65 | 
             
                @runner.report.map { |puked| MiniTestResult.parse_failure(puked) }.compact
         | 
| 66 66 | 
             
              end
         | 
| 67 | 
            -
             | 
| 67 | 
            +
             | 
| 68 68 | 
             
              def errors
         | 
| 69 69 | 
             
                @runner.report.map { |puked| MiniTestResult.parse_error(puked) }.compact
         | 
| 70 70 | 
             
              end
         | 
| 71 | 
            -
             | 
| 71 | 
            +
             | 
| 72 72 | 
             
              def failure_messages
         | 
| 73 73 | 
             
                failures.map(&:message)
         | 
| 74 74 | 
             
              end
         | 
| 75 | 
            -
             | 
| 75 | 
            +
             | 
| 76 76 | 
             
              def failure_message_lines
         | 
| 77 77 | 
             
                failure_messages.map { |message| message.split("\n") }.flatten
         | 
| 78 78 | 
             
              end
         | 
| 79 | 
            -
             | 
| 79 | 
            +
             | 
| 80 80 | 
             
              def error_messages
         | 
| 81 81 | 
             
                errors.map { |e| e.exception.message }
         | 
| 82 82 | 
             
              end
         |