rspec 1.2.2 → 1.2.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/History.rdoc +31 -1
- data/Manifest.txt +14 -12
- data/Rakefile +1 -1
- data/Upgrade.rdoc +43 -3
- data/examples/failing/failing_implicit_docstrings_example.rb +5 -5
- data/examples/passing/implicit_docstrings_example.rb +3 -3
- data/features/before_and_after_blocks/before_and_after_blocks.feature +20 -21
- data/features/example_groups/example_group_with_should_methods.feature +20 -8
- data/features/example_groups/implicit_docstrings.feature +36 -20
- data/features/example_groups/nested_groups.feature +25 -10
- data/features/extensions/custom_example_group.feature +19 -0
- data/features/formatters/custom_formatter.feature +30 -0
- data/features/heckle/heckle.feature +7 -7
- data/features/interop/examples_and_tests_together.feature +63 -14
- data/features/interop/rspec_output.feature +25 -0
- data/features/interop/test_but_not_test_unit.feature +19 -7
- data/features/interop/test_case_with_should_methods.feature +37 -8
- data/features/matchers/{create_matcher.feature → define_matcher.feature} +54 -30
- data/features/matchers/{create_matcher_outside_rspec.feature → define_matcher_outside_rspec.feature} +7 -7
- data/features/mock_framework_integration/use_flexmock.feature +3 -3
- data/features/mock_framework_integration/use_mocha.feature +3 -3
- data/features/mock_framework_integration/use_rr.feature +3 -3
- data/features/mocks/mix_stubs_and_mocks.feature +4 -4
- data/features/pending/pending_examples.feature +18 -18
- data/features/runner/specify_line_number.feature +32 -0
- data/features/step_definitions/running_rspec_steps.rb +41 -0
- data/features/subject/explicit_subject.feature +4 -4
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +64 -11
- data/features/support/matchers/smart_match.rb +10 -35
- data/lib/spec.rb +1 -0
- data/lib/spec/deprecation.rb +40 -0
- data/lib/spec/dsl/main.rb +10 -5
- data/lib/spec/example.rb +1 -27
- data/lib/spec/example/args_and_options.rb +27 -0
- data/lib/spec/example/before_and_after_hooks.rb +30 -21
- data/lib/spec/example/errors.rb +8 -18
- data/lib/spec/example/example_group_factory.rb +0 -4
- data/lib/spec/example/example_group_methods.rb +27 -41
- data/lib/spec/example/example_group_proxy.rb +12 -22
- data/lib/spec/example/example_methods.rb +8 -18
- data/lib/spec/example/example_proxy.rb +4 -4
- data/lib/spec/example/pending.rb +3 -4
- data/lib/spec/example/predicate_matchers.rb +1 -1
- data/lib/spec/example/subject.rb +2 -0
- data/lib/spec/expectations.rb +1 -26
- data/lib/spec/expectations/extensions.rb +1 -1
- data/lib/spec/expectations/extensions/kernel.rb +52 -0
- data/lib/spec/expectations/handler.rb +21 -10
- data/lib/spec/matchers/be.rb +3 -3
- data/lib/spec/matchers/be_close.rb +17 -21
- data/lib/spec/matchers/be_instance_of.rb +7 -26
- data/lib/spec/matchers/be_kind_of.rb +7 -26
- data/lib/spec/matchers/dsl.rb +9 -4
- data/lib/spec/matchers/eql.rb +24 -25
- data/lib/spec/matchers/equal.rb +25 -25
- data/lib/spec/matchers/exist.rb +5 -21
- data/lib/spec/matchers/include.rb +22 -44
- data/lib/spec/matchers/match.rb +5 -25
- data/lib/spec/matchers/match_array.rb +8 -4
- data/lib/spec/matchers/matcher.rb +13 -2
- data/lib/spec/matchers/pretty.rb +1 -0
- data/lib/spec/matchers/simple_matcher.rb +2 -2
- data/lib/spec/mocks/mock.rb +10 -10
- data/lib/spec/mocks/spec_methods.rb +1 -1
- data/lib/spec/runner/configuration.rb +53 -42
- data/lib/spec/{expectations → runner}/differs/default.rb +0 -0
- data/lib/spec/{expectations → runner}/differs/load-diff-lcs.rb +0 -0
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/example_group_runner.rb +0 -12
- data/lib/spec/runner/formatter/base_formatter.rb +77 -30
- data/lib/spec/runner/formatter/base_text_formatter.rb +19 -24
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +1 -1
- data/lib/spec/runner/formatter/html_formatter.rb +4 -6
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/no_op_method_missing.rb +21 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +0 -4
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +4 -5
- data/lib/spec/runner/formatter/silent_formatter.rb +10 -0
- data/lib/spec/runner/formatter/specdoc_formatter.rb +2 -2
- data/lib/spec/runner/option_parser.rb +14 -7
- data/lib/spec/runner/options.rb +17 -7
- data/lib/spec/runner/reporter.rb +69 -64
- data/lib/spec/version.rb +1 -1
- data/spec/spec/dsl/main_spec.rb +7 -0
- data/spec/spec/example/example_group_methods_spec.rb +16 -32
- data/spec/spec/example/example_group_proxy_spec.rb +25 -5
- data/spec/spec/example/example_group_spec.rb +2 -2
- data/spec/spec/example/example_methods_spec.rb +19 -24
- data/spec/spec/example/example_proxy_spec.rb +11 -1
- data/spec/spec/example/pending_module_spec.rb +2 -108
- data/spec/spec/example/predicate_matcher_spec.rb +23 -3
- data/spec/spec/expectations/extensions/object_spec.rb +9 -9
- data/spec/spec/expectations/fail_with_spec.rb +13 -13
- data/spec/spec/expectations/handler_spec.rb +44 -15
- data/spec/spec/matchers/be_close_spec.rb +9 -0
- data/spec/spec/matchers/be_instance_of_spec.rb +6 -4
- data/spec/spec/matchers/be_kind_of_spec.rb +5 -3
- data/spec/spec/matchers/be_spec.rb +1 -5
- data/spec/spec/matchers/compatibility_spec.rb +1 -1
- data/spec/spec/matchers/dsl_spec.rb +10 -1
- data/spec/spec/matchers/eql_spec.rb +8 -4
- data/spec/spec/matchers/equal_spec.rb +8 -4
- data/spec/spec/matchers/exist_spec.rb +1 -1
- data/spec/spec/matchers/include_spec.rb +1 -1
- data/spec/spec/matchers/match_array_spec.rb +26 -1
- data/spec/spec/matchers/match_spec.rb +2 -2
- data/spec/spec/matchers/matcher_methods_spec.rb +0 -3
- data/spec/spec/matchers/matcher_spec.rb +53 -0
- data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
- data/spec/spec/mocks/mock_spec.rb +6 -0
- data/spec/spec/runner/configuration_spec.rb +11 -1
- data/spec/spec/runner/drb_command_line_spec.rb +13 -1
- data/spec/spec/runner/example_group_runner_spec.rb +0 -7
- data/spec/spec/runner/formatter/base_formatter_spec.rb +19 -12
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +31 -34
- data/spec/spec/runner/formatter/html_formatter_spec.rb +20 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -20
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +22 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +24 -3
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +25 -28
- data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/option_parser_spec.rb +108 -40
- data/spec/spec/runner/reporter_spec.rb +16 -17
- data/spec/spec_helper.rb +4 -1
- metadata +20 -18
- data/features/example_groups/output.feature +0 -20
- data/features/step_definitions/running_rspec.rb +0 -69
- data/lib/spec/expectations/extensions/object.rb +0 -63
- data/resources/spec/example_group_with_should_methods.rb +0 -12
- data/resources/spec/simple_spec.rb +0 -8
- data/resources/test/spec_and_test_together.rb +0 -56
- data/resources/test/spec_including_test_but_not_unit.rb +0 -11
- data/resources/test/test_case_with_should_methods.rb +0 -29
| @@ -1,28 +1,5 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
                class BeKindOf
         | 
| 4 | 
            -
                  def initialize(expected)
         | 
| 5 | 
            -
                    @expected = expected
         | 
| 6 | 
            -
                  end
         | 
| 7 | 
            -
                  
         | 
| 8 | 
            -
                  def matches?(actual)
         | 
| 9 | 
            -
                    @actual = actual
         | 
| 10 | 
            -
                    @actual.kind_of?(@expected)
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
                  
         | 
| 13 | 
            -
                  def description
         | 
| 14 | 
            -
                    "be a kind of #{@expected}"
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
                  
         | 
| 17 | 
            -
                  def failure_message_for_should
         | 
| 18 | 
            -
                    "expected kind of #{@expected}, got #{@actual.inspect}"
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
                  
         | 
| 21 | 
            -
                  def failure_message_for_should_not
         | 
| 22 | 
            -
                    "expected #{@actual.inspect} not to be a kind of #{@expected}"
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
             | 
| 26 3 | 
             
                # :call-seq:
         | 
| 27 4 | 
             
                #   should be_kind_of(expected)
         | 
| 28 5 | 
             
                #   should be_a_kind_of(expected)
         | 
| @@ -36,10 +13,14 @@ module Spec | |
| 36 13 | 
             
                #   5.should be_kind_of(Fixnum)
         | 
| 37 14 | 
             
                #   5.should be_kind_of(Numeric)
         | 
| 38 15 | 
             
                #   5.should_not be_kind_of(Float)
         | 
| 39 | 
            -
                def  | 
| 40 | 
            -
                   | 
| 16 | 
            +
                def be_a_kind_of(expected)
         | 
| 17 | 
            +
                  Matcher.new :be_a_kind_of, expected do |expected|
         | 
| 18 | 
            +
                    match do |actual|
         | 
| 19 | 
            +
                      actual.kind_of?(expected)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 41 22 | 
             
                end
         | 
| 42 23 |  | 
| 43 | 
            -
                alias_method : | 
| 24 | 
            +
                alias_method :be_kind_of, :be_a_kind_of
         | 
| 44 25 | 
             
              end
         | 
| 45 26 | 
             
            end
         | 
    
        data/lib/spec/matchers/dsl.rb
    CHANGED
    
    | @@ -1,15 +1,20 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 3 | 
             
                module DSL
         | 
| 4 | 
            -
                   | 
| 4 | 
            +
                  # See Spec::Matchers
         | 
| 5 | 
            +
                  def define(name, &declarations)
         | 
| 5 6 | 
             
                    define_method name do |*expected|
         | 
| 6 | 
            -
                      Spec::Matchers::Matcher.new name, *expected, & | 
| 7 | 
            +
                      Spec::Matchers::Matcher.new name, *expected, &declarations
         | 
| 7 8 | 
             
                    end
         | 
| 8 9 | 
             
                  end
         | 
| 10 | 
            +
                  
         | 
| 11 | 
            +
                  # Deprecated - use define
         | 
| 12 | 
            +
                  def create(name, &declarations)
         | 
| 13 | 
            +
                    Spec.deprecate("Spec::Matchers.create","Spec::Matchers.define")
         | 
| 14 | 
            +
                    define(name, &declarations)
         | 
| 15 | 
            +
                  end
         | 
| 9 16 | 
             
                end
         | 
| 10 17 | 
             
              end
         | 
| 11 18 | 
             
            end
         | 
| 12 19 |  | 
| 13 20 | 
             
            Spec::Matchers.extend Spec::Matchers::DSL
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  
         | 
    
        data/lib/spec/matchers/eql.rb
    CHANGED
    
    | @@ -1,29 +1,5 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
                class Eql
         | 
| 4 | 
            -
                  def initialize(expected)
         | 
| 5 | 
            -
                    @expected = expected
         | 
| 6 | 
            -
                  end
         | 
| 7 | 
            -
                  
         | 
| 8 | 
            -
                  def matches?(actual)
         | 
| 9 | 
            -
                    @actual = actual
         | 
| 10 | 
            -
                    @actual.eql?(@expected)
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
                  
         | 
| 13 | 
            -
                  def failure_message_for_should
         | 
| 14 | 
            -
                    return "expected #{@expected.inspect}, got #{@actual.inspect} (using .eql?)", @expected, @actual
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
                  
         | 
| 17 | 
            -
                  def failure_message_for_should_not
         | 
| 18 | 
            -
                    return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @actual
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
                  
         | 
| 21 | 
            -
                  def description
         | 
| 22 | 
            -
                    "eql #{@expected.inspect}"
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
                
         | 
| 26 | 
            -
              
         | 
| 27 3 | 
             
                # :call-seq:
         | 
| 28 4 | 
             
                #   should eql(expected)
         | 
| 29 5 | 
             
                #   should_not eql(expected)
         | 
| @@ -37,7 +13,30 @@ module Spec | |
| 37 13 | 
             
                #   5.should eql(5)
         | 
| 38 14 | 
             
                #   5.should_not eql(3)
         | 
| 39 15 | 
             
                def eql(expected)
         | 
| 40 | 
            -
                   | 
| 16 | 
            +
                  Matcher.new :eql, expected do |expected|
         | 
| 17 | 
            +
                    match do |actual|
         | 
| 18 | 
            +
                      actual.eql?(expected)
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    failure_message_for_should do |actual|
         | 
| 22 | 
            +
                      <<-MESSAGE
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            expected #{expected.inspect}
         | 
| 25 | 
            +
                 got #{actual.inspect}
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            (compared using eql?)
         | 
| 28 | 
            +
            MESSAGE
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    failure_message_for_should_not do |actual|
         | 
| 32 | 
            +
                      <<-MESSAGE
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            expected #{actual.inspect} not to equal #{expected.inspect}
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            (compared using eql?)
         | 
| 37 | 
            +
            MESSAGE
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                  end
         | 
| 41 40 | 
             
                end
         | 
| 42 41 | 
             
              end
         | 
| 43 42 | 
             
            end
         | 
    
        data/lib/spec/matchers/equal.rb
    CHANGED
    
    | @@ -1,29 +1,6 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                class Equal
         | 
| 5 | 
            -
                  def initialize(expected)
         | 
| 6 | 
            -
                    @expected = expected
         | 
| 7 | 
            -
                  end
         | 
| 8 | 
            -
                  
         | 
| 9 | 
            -
                  def matches?(actual)
         | 
| 10 | 
            -
                    @actual = actual
         | 
| 11 | 
            -
                    @actual.equal?(@expected)
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
                  
         | 
| 14 | 
            -
                  def failure_message_for_should
         | 
| 15 | 
            -
                    return "expected #{@expected.inspect}, got #{@actual.inspect} (using .equal?)", @expected, @actual
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
                  
         | 
| 18 | 
            -
                  def failure_message_for_should_not
         | 
| 19 | 
            -
                    return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .equal?)", @expected, @actual
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                  
         | 
| 22 | 
            -
                  def description
         | 
| 23 | 
            -
                    "equal #{@expected.inspect}"
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              
         | 
| 3 | 
            +
             | 
| 27 4 | 
             
                # :call-seq:
         | 
| 28 5 | 
             
                #   should equal(expected)
         | 
| 29 6 | 
             
                #   should_not equal(expected)
         | 
| @@ -37,7 +14,30 @@ module Spec | |
| 37 14 | 
             
                #   5.should equal(5) #Fixnums are equal
         | 
| 38 15 | 
             
                #   "5".should_not equal("5") #Strings that look the same are not the same object
         | 
| 39 16 | 
             
                def equal(expected)
         | 
| 40 | 
            -
                   | 
| 17 | 
            +
                  Matcher.new :equal, expected do |expected|
         | 
| 18 | 
            +
                    match do |actual|
         | 
| 19 | 
            +
                      actual.equal?(expected)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                    
         | 
| 22 | 
            +
                    failure_message_for_should do |actual|
         | 
| 23 | 
            +
                      <<-MESSAGE
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            expected #{expected.inspect}
         | 
| 26 | 
            +
                 got #{actual.inspect}
         | 
| 27 | 
            +
                 
         | 
| 28 | 
            +
            (compared using equal?)
         | 
| 29 | 
            +
            MESSAGE
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    failure_message_for_should_not do |actual|
         | 
| 33 | 
            +
                      <<-MESSAGE
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            expected #{actual.inspect} not to equal #{expected.inspect}
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            (compared using equal?)
         | 
| 38 | 
            +
            MESSAGE
         | 
| 39 | 
            +
                    end
         | 
| 40 | 
            +
                  end
         | 
| 41 41 | 
             
                end
         | 
| 42 42 | 
             
              end
         | 
| 43 43 | 
             
            end
         | 
    
        data/lib/spec/matchers/exist.rb
    CHANGED
    
    | @@ -1,32 +1,16 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                class Exist
         | 
| 5 | 
            -
                  def matches?(actual)
         | 
| 6 | 
            -
                    @actual = actual
         | 
| 7 | 
            -
                    actual.exist?
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def failure_message_for_should
         | 
| 11 | 
            -
                    "expected #{@actual.inspect} to exist, but it doesn't."
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  def failure_message_for_should_not
         | 
| 15 | 
            -
                    "expected #{@actual.inspect} to not exist, but it does."
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                  def description
         | 
| 19 | 
            -
                    "exists"
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 3 | 
             
                # :call-seq:
         | 
| 24 4 | 
             
                #   should exist
         | 
| 25 5 | 
             
                #   should_not exist
         | 
| 26 6 | 
             
                #
         | 
| 27 7 | 
             
                # Passes if actual.exist?
         | 
| 28 8 | 
             
                def exist
         | 
| 29 | 
            -
                   | 
| 9 | 
            +
                  Matcher.new :exist do
         | 
| 10 | 
            +
                    match do |actual|
         | 
| 11 | 
            +
                      actual.exist?
         | 
| 12 | 
            +
                    end
         | 
| 13 | 
            +
                  end
         | 
| 30 14 | 
             
                end
         | 
| 31 15 | 
             
              end
         | 
| 32 16 | 
             
            end
         | 
| @@ -1,48 +1,5 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
                class Include #:nodoc:
         | 
| 4 | 
            -
                  include Spec::Matchers::Pretty
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  def initialize(*expecteds)
         | 
| 7 | 
            -
                    @expecteds = expecteds
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
                  
         | 
| 10 | 
            -
                  def matches?(actual)
         | 
| 11 | 
            -
                    @actual = actual
         | 
| 12 | 
            -
                    @expecteds.each do |expected|
         | 
| 13 | 
            -
                      if actual.is_a?(Hash)
         | 
| 14 | 
            -
                        if expected.is_a?(Hash)
         | 
| 15 | 
            -
                          expected.each_pair do |k,v|
         | 
| 16 | 
            -
                            return false unless actual[k] == v
         | 
| 17 | 
            -
                          end
         | 
| 18 | 
            -
                        else
         | 
| 19 | 
            -
                          return false unless actual.has_key?(expected)
         | 
| 20 | 
            -
                        end
         | 
| 21 | 
            -
                      else
         | 
| 22 | 
            -
                        return false unless actual.include?(expected)
         | 
| 23 | 
            -
                      end
         | 
| 24 | 
            -
                    end
         | 
| 25 | 
            -
                    true
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
                  
         | 
| 28 | 
            -
                  def failure_message_for_should
         | 
| 29 | 
            -
                    _message
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
                  
         | 
| 32 | 
            -
                  def failure_message_for_should_not
         | 
| 33 | 
            -
                    _message("not ")
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
                  
         | 
| 36 | 
            -
                  def description
         | 
| 37 | 
            -
                    "include #{_pretty_print(@expecteds)}"
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
                  
         | 
| 40 | 
            -
                  private
         | 
| 41 | 
            -
                    def _message(maybe_not="")
         | 
| 42 | 
            -
                      "expected #{@actual.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
         | 
| 43 | 
            -
                    end
         | 
| 44 | 
            -
                end
         | 
| 45 | 
            -
             | 
| 46 3 | 
             
                # :call-seq:
         | 
| 47 4 | 
             
                #   should include(expected)
         | 
| 48 5 | 
             
                #   should_not include(expected)
         | 
| @@ -60,7 +17,28 @@ module Spec | |
| 60 17 | 
             
                #   "spread".should include("read")
         | 
| 61 18 | 
             
                #   "spread".should_not include("red")
         | 
| 62 19 | 
             
                def include(*expected)
         | 
| 63 | 
            -
                   | 
| 20 | 
            +
                  Matcher.new :include, *expected do |*expecteds|
         | 
| 21 | 
            +
                    match do |actual|
         | 
| 22 | 
            +
                      helper(actual, *expecteds)
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                    
         | 
| 25 | 
            +
                    def helper(actual, *expecteds)
         | 
| 26 | 
            +
                      expecteds.each do |expected|
         | 
| 27 | 
            +
                        if actual.is_a?(Hash)
         | 
| 28 | 
            +
                          if expected.is_a?(Hash)
         | 
| 29 | 
            +
                            expected.each_pair do |k,v|
         | 
| 30 | 
            +
                              return false unless actual[k] == v
         | 
| 31 | 
            +
                            end
         | 
| 32 | 
            +
                          else
         | 
| 33 | 
            +
                            return false unless actual.has_key?(expected)
         | 
| 34 | 
            +
                          end
         | 
| 35 | 
            +
                        else
         | 
| 36 | 
            +
                          return false unless actual.include?(expected)
         | 
| 37 | 
            +
                        end
         | 
| 38 | 
            +
                      end
         | 
| 39 | 
            +
                      true
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                  end
         | 
| 64 42 | 
             
                end
         | 
| 65 43 | 
             
              end
         | 
| 66 44 | 
             
            end
         | 
    
        data/lib/spec/matchers/match.rb
    CHANGED
    
    | @@ -1,29 +1,5 @@ | |
| 1 1 | 
             
            module Spec
         | 
| 2 2 | 
             
              module Matchers
         | 
| 3 | 
            -
                class Match
         | 
| 4 | 
            -
                  def initialize(expected)
         | 
| 5 | 
            -
                    @expected = expected
         | 
| 6 | 
            -
                  end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  def matches?(actual)
         | 
| 9 | 
            -
                    @actual = actual
         | 
| 10 | 
            -
                    actual =~ @expected
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def failure_message_for_should
         | 
| 14 | 
            -
                    return "expected #{@actual.inspect} to match #{@expected.inspect}", @expected, @actual
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  def failure_message_for_should_not
         | 
| 18 | 
            -
                    return "expected #{@actual.inspect} not to match #{@expected.inspect}", @expected, @actual
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  def description
         | 
| 22 | 
            -
                    "match #{@expected.inspect}"
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
                
         | 
| 26 | 
            -
                
         | 
| 27 3 | 
             
                # :call-seq:
         | 
| 28 4 | 
             
                #   should match(regexp)
         | 
| 29 5 | 
             
                #   should_not match(regexp)
         | 
| @@ -34,7 +10,11 @@ module Spec | |
| 34 10 | 
             
                #
         | 
| 35 11 | 
             
                #   email.should match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
         | 
| 36 12 | 
             
                def match(expected)
         | 
| 37 | 
            -
                   | 
| 13 | 
            +
                  Matcher.new :match, expected do |expected|
         | 
| 14 | 
            +
                    match do |actual|
         | 
| 15 | 
            +
                      actual =~ expected
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 38 18 | 
             
                end
         | 
| 39 19 | 
             
              end
         | 
| 40 20 | 
             
            end
         | 
| @@ -16,10 +16,10 @@ module Spec | |
| 16 16 | 
             
                  end
         | 
| 17 17 |  | 
| 18 18 | 
             
                  def failure_message_for_should
         | 
| 19 | 
            -
                    message =  "expected collection contained:  #{@expected. | 
| 20 | 
            -
                    message += "actual collection contained:    #{@actual. | 
| 21 | 
            -
                    message += "the missing elements were:      #{@missing_items. | 
| 22 | 
            -
                    message += "the extra elements were:        #{@extra_items. | 
| 19 | 
            +
                    message =  "expected collection contained:  #{safe_sort(@expected).inspect}\n"
         | 
| 20 | 
            +
                    message += "actual collection contained:    #{safe_sort(@actual).inspect}\n"
         | 
| 21 | 
            +
                    message += "the missing elements were:      #{safe_sort(@missing_items).inspect}\n" unless @missing_items.empty?
         | 
| 22 | 
            +
                    message += "the extra elements were:        #{safe_sort(@extra_items).inspect}\n"   unless @extra_items.empty?
         | 
| 23 23 | 
             
                    message
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| @@ -33,6 +33,10 @@ module Spec | |
| 33 33 |  | 
| 34 34 | 
             
                  private
         | 
| 35 35 |  | 
| 36 | 
            +
                    def safe_sort(array)
         | 
| 37 | 
            +
                      array.all?{|item| item.respond_to?(:<=>)} ? array.sort : array
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 36 40 | 
             
                    def difference_between_arrays(array_1, array_2)
         | 
| 37 41 | 
             
                      difference = array_1.dup
         | 
| 38 42 | 
             
                      array_2.each do |element|
         | 
| @@ -3,14 +3,17 @@ module Spec | |
| 3 3 | 
             
                class Matcher
         | 
| 4 4 | 
             
                  include Spec::Matchers::Pretty
         | 
| 5 5 |  | 
| 6 | 
            +
                  attr_reader :expected, :actual
         | 
| 7 | 
            +
                  
         | 
| 6 8 | 
             
                  def initialize(name, *expected, &declarations)
         | 
| 7 9 | 
             
                    @name = name
         | 
| 8 10 | 
             
                    @expected = expected
         | 
| 9 11 | 
             
                    @declarations = declarations
         | 
| 12 | 
            +
                    @diffable = false
         | 
| 10 13 | 
             
                    @messages = {
         | 
| 11 14 | 
             
                      :description => lambda {"#{name_to_sentence}#{expected_to_sentence}"},
         | 
| 12 | 
            -
                      :failure_message_for_should => lambda {|actual| "expected #{actual} to #{name_to_sentence}#{expected_to_sentence}"},
         | 
| 13 | 
            -
                      :failure_message_for_should_not => lambda {|actual| "expected #{actual} not to #{name_to_sentence}#{expected_to_sentence}"}
         | 
| 15 | 
            +
                      :failure_message_for_should => lambda {|actual| "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"},
         | 
| 16 | 
            +
                      :failure_message_for_should_not => lambda {|actual| "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"}
         | 
| 14 17 | 
             
                    }
         | 
| 15 18 | 
             
                  end
         | 
| 16 19 |  | 
| @@ -36,6 +39,14 @@ module Spec | |
| 36 39 | 
             
                    @match_block = block
         | 
| 37 40 | 
             
                  end
         | 
| 38 41 |  | 
| 42 | 
            +
                  def diffable?
         | 
| 43 | 
            +
                    @diffable
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                  
         | 
| 46 | 
            +
                  def diffable
         | 
| 47 | 
            +
                    @diffable = true
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                  
         | 
| 39 50 | 
             
                private
         | 
| 40 51 |  | 
| 41 52 | 
             
                  def cache_or_call_cached(key, actual=nil, &block)
         | 
    
        data/lib/spec/matchers/pretty.rb
    CHANGED
    
    
| @@ -23,11 +23,11 @@ module Spec | |
| 23 23 | 
             
                    @description || explanation
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| 26 | 
            -
                  def  | 
| 26 | 
            +
                  def failure_message_for_should
         | 
| 27 27 | 
             
                    @failure_message || (@description.nil? ? explanation : %[expected #{@description.inspect} but got #{@given.inspect}])
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 | 
            -
                  def  | 
| 30 | 
            +
                  def failure_message_for_should_not
         | 
| 31 31 | 
             
                    @negative_failure_message || (@description.nil? ? explanation : %[expected not to get #{@description.inspect}, but got #{@given.inspect}])
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 |  | 
    
        data/lib/spec/mocks/mock.rb
    CHANGED
    
    | @@ -21,16 +21,6 @@ module Spec | |
| 21 21 | 
             
                    other == __mock_proxy
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 | 
            -
                  def method_missing(sym, *args, &block)
         | 
| 25 | 
            -
                    __mock_proxy.record_message_received(sym, args, block)
         | 
| 26 | 
            -
                    begin
         | 
| 27 | 
            -
                      return self if __mock_proxy.null_object?
         | 
| 28 | 
            -
                      super(sym, *args, &block)
         | 
| 29 | 
            -
                    rescue NameError
         | 
| 30 | 
            -
                      __mock_proxy.raise_unexpected_message_error sym, *args
         | 
| 31 | 
            -
                    end
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                  
         | 
| 34 24 | 
             
                  def inspect
         | 
| 35 25 | 
             
                    "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>"
         | 
| 36 26 | 
             
                  end
         | 
| @@ -40,6 +30,16 @@ module Spec | |
| 40 30 | 
             
                  end
         | 
| 41 31 |  | 
| 42 32 | 
             
                  private
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                    def method_missing(sym, *args, &block)
         | 
| 35 | 
            +
                      __mock_proxy.record_message_received(sym, args, block)
         | 
| 36 | 
            +
                      begin
         | 
| 37 | 
            +
                        return self if __mock_proxy.null_object?
         | 
| 38 | 
            +
                        super(sym, *args, &block)
         | 
| 39 | 
            +
                      rescue NameError
         | 
| 40 | 
            +
                        __mock_proxy.raise_unexpected_message_error sym, *args
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 43 |  | 
| 44 44 | 
             
                    def parse_options(options)
         | 
| 45 45 | 
             
                      options.has_key?(:null_object) ? {:null_object => options.delete(:null_object)} : {}
         |