rspec-mocks 2.12.1 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +17 -0
- data/lib/rspec/mocks.rb +8 -0
- data/lib/rspec/mocks/message_expectation.rb +6 -11
- data/lib/rspec/mocks/method_double.rb +19 -2
- data/lib/rspec/mocks/mutate_const.rb +1 -1
- data/lib/rspec/mocks/proxy.rb +1 -1
- data/lib/rspec/mocks/version.rb +1 -1
- data/lib/spec/mocks.rb +4 -0
- data/spec/rspec/mocks/and_call_original_spec.rb +22 -0
- data/spec/rspec/mocks/and_yield_spec.rb +7 -7
- data/spec/rspec/mocks/any_instance/message_chains_spec.rb +6 -6
- data/spec/rspec/mocks/any_instance_spec.rb +94 -94
- data/spec/rspec/mocks/any_number_of_times_spec.rb +2 -2
- data/spec/rspec/mocks/argument_expectation_spec.rb +3 -3
- data/spec/rspec/mocks/at_least_spec.rb +15 -15
- data/spec/rspec/mocks/at_most_spec.rb +7 -7
- data/spec/rspec/mocks/block_return_value_spec.rb +6 -6
- data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_10263_spec.rb +6 -4
- data/spec/rspec/mocks/bug_report_11545_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_600_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_8165_spec.rb +4 -4
- data/spec/rspec/mocks/bug_report_830_spec.rb +2 -2
- data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
- data/spec/rspec/mocks/configuration_spec.rb +4 -4
- data/spec/rspec/mocks/double_spec.rb +1 -1
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +1 -1
- data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +13 -13
- data/spec/rspec/mocks/hash_including_matcher_spec.rb +30 -30
- data/spec/rspec/mocks/mock_ordering_spec.rb +8 -8
- data/spec/rspec/mocks/mock_space_spec.rb +4 -4
- data/spec/rspec/mocks/mock_spec.rb +94 -90
- data/spec/rspec/mocks/multiple_return_value_spec.rb +21 -21
- data/spec/rspec/mocks/mutate_const_spec.rb +112 -102
- data/spec/rspec/mocks/nil_expectation_warning_spec.rb +6 -12
- data/spec/rspec/mocks/null_object_mock_spec.rb +12 -12
- data/spec/rspec/mocks/once_counts_spec.rb +7 -7
- data/spec/rspec/mocks/options_hash_spec.rb +6 -6
- data/spec/rspec/mocks/partial_mock_spec.rb +15 -15
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +17 -17
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +6 -6
- data/spec/rspec/mocks/precise_counts_spec.rb +7 -7
- data/spec/rspec/mocks/record_messages_spec.rb +4 -4
- data/spec/rspec/mocks/serialization_spec.rb +3 -3
- data/spec/rspec/mocks/stash_spec.rb +1 -1
- data/spec/rspec/mocks/stub_chain_spec.rb +22 -22
- data/spec/rspec/mocks/stub_implementation_spec.rb +10 -10
- data/spec/rspec/mocks/stub_spec.rb +50 -31
- data/spec/rspec/mocks/stubbed_message_expectations_spec.rb +3 -3
- data/spec/rspec/mocks/test_double_spec.rb +3 -3
- data/spec/rspec/mocks/to_ary_spec.rb +7 -7
- data/spec/rspec/mocks/twice_counts_spec.rb +8 -8
- data/spec/rspec/mocks_spec.rb +13 -4
- data/spec/spec_helper.rb +4 -0
- metadata +5 -5
| @@ -11,7 +11,6 @@ end | |
| 11 11 |  | 
| 12 12 | 
             
            module RSpec
         | 
| 13 13 | 
             
              module Mocks
         | 
| 14 | 
            -
             | 
| 15 14 | 
             
                describe "an expectation set on nil" do
         | 
| 16 15 | 
             
                  it "issues a warning with file and line number information" do
         | 
| 17 16 | 
             
                    expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in .+)?. Use allow_message_expectations_on_nil to disable warnings.%
         | 
| @@ -20,27 +19,24 @@ module RSpec | |
| 20 19 | 
             
                    nil.should_receive(:foo)
         | 
| 21 20 | 
             
                    nil.foo
         | 
| 22 21 | 
             
                  end
         | 
| 23 | 
            -
             | 
| 22 | 
            +
             | 
| 24 23 | 
             
                  it "issues a warning when the expectation is negative" do
         | 
| 25 24 | 
             
                    Kernel.should_receive(:warn)
         | 
| 26 25 |  | 
| 27 26 | 
             
                    nil.should_not_receive(:foo)
         | 
| 28 27 | 
             
                  end
         | 
| 29 | 
            -
             | 
| 28 | 
            +
             | 
| 30 29 | 
             
                  it "does not issue a warning when expectations are set to be allowed" do
         | 
| 31 30 | 
             
                    allow_message_expectations_on_nil
         | 
| 32 31 | 
             
                    Kernel.should_not_receive(:warn)
         | 
| 33 | 
            -
             | 
| 32 | 
            +
             | 
| 34 33 | 
             
                    nil.should_receive(:foo)
         | 
| 35 34 | 
             
                    nil.should_not_receive(:bar)
         | 
| 36 35 | 
             
                    nil.foo
         | 
| 37 36 | 
             
                  end
         | 
| 38 | 
            -
             | 
| 39 37 | 
             
                end
         | 
| 40 | 
            -
                
         | 
| 41 | 
            -
                describe "#allow_message_expectations_on_nil" do
         | 
| 42 | 
            -
                  
         | 
| 43 38 |  | 
| 39 | 
            +
                describe "#allow_message_expectations_on_nil" do
         | 
| 44 40 | 
             
                  it "does not effect subsequent examples" do
         | 
| 45 41 | 
             
                    example_group = empty_example_group
         | 
| 46 42 | 
             
                    example_group.it("when called in one example that doesn't end up setting an expectation on nil") do
         | 
| @@ -51,12 +47,10 @@ module RSpec | |
| 51 47 | 
             
                                    nil.should_receive(:foo)
         | 
| 52 48 | 
             
                                    nil.foo
         | 
| 53 49 | 
             
                                  end
         | 
| 54 | 
            -
             | 
| 50 | 
            +
             | 
| 55 51 | 
             
                    example_group
         | 
| 56 | 
            -
                              
         | 
| 57 52 | 
             
                  end
         | 
| 58 | 
            -
             | 
| 59 53 | 
             
                end
         | 
| 60 | 
            -
                
         | 
| 61 54 | 
             
              end
         | 
| 62 55 | 
             
            end
         | 
| 56 | 
            +
             | 
| @@ -8,12 +8,12 @@ module RSpec | |
| 8 8 | 
             
                  end
         | 
| 9 9 |  | 
| 10 10 | 
             
                  it "says it does not respond to messages it doesn't understand" do
         | 
| 11 | 
            -
                    @double. | 
| 11 | 
            +
                    expect(@double).not_to respond_to(:foo)
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| 14 14 | 
             
                  it "says it responds to messages it does understand" do
         | 
| 15 15 | 
             
                    @double.stub(:foo)
         | 
| 16 | 
            -
                    @double. | 
| 16 | 
            +
                    expect(@double).to respond_to(:foo)
         | 
| 17 17 | 
             
                  end
         | 
| 18 18 |  | 
| 19 19 | 
             
                  it "raises an error when interpolated in a string as an integer" do
         | 
| @@ -33,12 +33,12 @@ module RSpec | |
| 33 33 | 
             
                  end
         | 
| 34 34 |  | 
| 35 35 | 
             
                  it "says it responds to everything" do
         | 
| 36 | 
            -
                    @double. | 
| 36 | 
            +
                    expect(@double).to respond_to(:any_message_it_gets)
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 39 | 
             
                  it "allows explicit stubs" do
         | 
| 40 40 | 
             
                    @double.stub(:foo) { "bar" }
         | 
| 41 | 
            -
                    @double.foo. | 
| 41 | 
            +
                    expect(@double.foo).to eq("bar")
         | 
| 42 42 | 
             
                  end
         | 
| 43 43 |  | 
| 44 44 | 
             
                  it "allows explicit expectation" do
         | 
| @@ -48,20 +48,20 @@ module RSpec | |
| 48 48 |  | 
| 49 49 | 
             
                  it 'continues to return self from an explicit expectation' do
         | 
| 50 50 | 
             
                    @double.should_receive(:bar)
         | 
| 51 | 
            -
                    @double.foo.bar. | 
| 51 | 
            +
                    expect(@double.foo.bar).to be(@double)
         | 
| 52 52 | 
             
                  end
         | 
| 53 53 |  | 
| 54 54 | 
             
                  it 'returns an explicitly stubbed value from an expectation with no implementation' do
         | 
| 55 55 | 
             
                    @double.stub(:foo => "bar")
         | 
| 56 56 | 
             
                    @double.should_receive(:foo)
         | 
| 57 | 
            -
                    @double.foo. | 
| 57 | 
            +
                    expect(@double.foo).to eq("bar")
         | 
| 58 58 | 
             
                  end
         | 
| 59 59 |  | 
| 60 60 | 
             
                  it "fails verification when explicit exception not met" do
         | 
| 61 | 
            -
                     | 
| 61 | 
            +
                    expect {
         | 
| 62 62 | 
             
                      @double.should_receive(:something)
         | 
| 63 63 | 
             
                      @double.rspec_verify
         | 
| 64 | 
            -
                     | 
| 64 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 65 65 | 
             
                  end
         | 
| 66 66 |  | 
| 67 67 | 
             
                  it "ignores unexpected methods" do
         | 
| @@ -86,21 +86,21 @@ module RSpec | |
| 86 86 | 
             
                    # @double.to_int.to_int.to_int...etc until it gets an integer,
         | 
| 87 87 | 
             
                    # and thus gets stuck in an infinite loop unless our double
         | 
| 88 88 | 
             
                    # returns an int value from #to_int.
         | 
| 89 | 
            -
                    ("%i" % @double). | 
| 89 | 
            +
                    expect(("%i" % @double)).to eq("0")
         | 
| 90 90 | 
             
                  end
         | 
| 91 91 | 
             
                end
         | 
| 92 | 
            -
             | 
| 92 | 
            +
             | 
| 93 93 | 
             
                describe "#as_null_object" do
         | 
| 94 94 | 
             
                  it "sets the object to null_object" do
         | 
| 95 95 | 
             
                    obj = double('anything').as_null_object
         | 
| 96 | 
            -
                    obj. | 
| 96 | 
            +
                    expect(obj).to be_null_object
         | 
| 97 97 | 
             
                  end
         | 
| 98 98 | 
             
                end
         | 
| 99 99 |  | 
| 100 100 | 
             
                describe "#null_object?" do
         | 
| 101 101 | 
             
                  it "defaults to false" do
         | 
| 102 102 | 
             
                    obj = double('anything')
         | 
| 103 | 
            -
                    obj. | 
| 103 | 
            +
                    expect(obj).not_to be_null_object
         | 
| 104 104 | 
             
                  end
         | 
| 105 105 | 
             
                end
         | 
| 106 106 | 
             
              end
         | 
| @@ -27,25 +27,25 @@ module RSpec | |
| 27 27 |  | 
| 28 28 | 
             
                  it "fails when called with wrong args" do
         | 
| 29 29 | 
             
                    @double.should_receive(:do_something).once.with("a", "b", "c")
         | 
| 30 | 
            -
                     | 
| 30 | 
            +
                    expect {
         | 
| 31 31 | 
             
                      @double.do_something("d", "e", "f")
         | 
| 32 | 
            -
                     | 
| 32 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 33 33 | 
             
                    @double.rspec_reset
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| 36 36 | 
             
                  it "fails fast when called twice" do
         | 
| 37 37 | 
             
                    @double.should_receive(:do_something).once
         | 
| 38 38 | 
             
                    @double.do_something
         | 
| 39 | 
            -
                     | 
| 39 | 
            +
                    expect {
         | 
| 40 40 | 
             
                      @double.do_something
         | 
| 41 | 
            -
                     | 
| 41 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 42 42 | 
             
                  end
         | 
| 43 | 
            -
             | 
| 43 | 
            +
             | 
| 44 44 | 
             
                  it "fails when not called" do
         | 
| 45 45 | 
             
                    @double.should_receive(:do_something).once
         | 
| 46 | 
            -
                     | 
| 46 | 
            +
                    expect {
         | 
| 47 47 | 
             
                      @double.rspec_verify
         | 
| 48 | 
            -
                     | 
| 48 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 49 49 | 
             
                  end
         | 
| 50 50 | 
             
                end
         | 
| 51 51 | 
             
              end
         | 
| @@ -10,25 +10,25 @@ module RSpec | |
| 10 10 | 
             
                      mock.rspec_verify
         | 
| 11 11 | 
             
                    rescue Exception => e
         | 
| 12 12 | 
             
                    ensure
         | 
| 13 | 
            -
                      e.backtrace.to_s. | 
| 13 | 
            +
                      expect(e.backtrace.to_s).to match /\/path\/to\/blah.ext:37/m
         | 
| 14 14 | 
             
                    end
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 17 | 
             
                  it "uses the message supplied with :message" do
         | 
| 18 | 
            -
                     | 
| 18 | 
            +
                    expect {
         | 
| 19 19 | 
             
                      m = RSpec::Mocks::Mock.new("a mock")
         | 
| 20 20 | 
             
                      m.should_receive(:message, :message => "recebi nada")
         | 
| 21 21 | 
             
                      m.rspec_verify
         | 
| 22 | 
            -
                    }. | 
| 22 | 
            +
                    }.to raise_error("recebi nada")
         | 
| 23 23 | 
             
                  end
         | 
| 24 | 
            -
             | 
| 24 | 
            +
             | 
| 25 25 | 
             
                  it "uses the message supplied with :message after a similar stub" do
         | 
| 26 | 
            -
                     | 
| 26 | 
            +
                    expect {
         | 
| 27 27 | 
             
                      m = RSpec::Mocks::Mock.new("a mock")
         | 
| 28 28 | 
             
                      m.stub(:message)
         | 
| 29 29 | 
             
                      m.should_receive(:message, :message => "from mock")
         | 
| 30 30 | 
             
                      m.rspec_verify
         | 
| 31 | 
            -
                    }. | 
| 31 | 
            +
                    }.to raise_error("from mock")
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 | 
             
                end
         | 
| 34 34 | 
             
              end
         | 
| @@ -14,9 +14,9 @@ module RSpec | |
| 14 14 |  | 
| 15 15 | 
             
                  it "names the class in the failure message when expectation is on class" do
         | 
| 16 16 | 
             
                    Object.should_receive(:foo)
         | 
| 17 | 
            -
                     | 
| 17 | 
            +
                    expect {
         | 
| 18 18 | 
             
                      Object.rspec_verify
         | 
| 19 | 
            -
                     | 
| 19 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError, /<Object \(class\)>/)
         | 
| 20 20 | 
             
                  end
         | 
| 21 21 |  | 
| 22 22 | 
             
                  it "does not conflict with @options in the object" do
         | 
| @@ -36,35 +36,35 @@ module RSpec | |
| 36 36 | 
             
                  end
         | 
| 37 37 |  | 
| 38 38 | 
             
                  it "should_not_receive returns a negative message expectation" do
         | 
| 39 | 
            -
                    object.should_not_receive(:foobar). | 
| 39 | 
            +
                    expect(object.should_not_receive(:foobar)).to be_kind_of(RSpec::Mocks::NegativeMessageExpectation)
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 42 | 
             
                  it "should_receive mocks out the method" do
         | 
| 43 43 | 
             
                    object.should_receive(:foobar).with(:test_param).and_return(1)
         | 
| 44 | 
            -
                    object.foobar(:test_param). | 
| 44 | 
            +
                    expect(object.foobar(:test_param)).to equal(1)
         | 
| 45 45 | 
             
                  end
         | 
| 46 46 |  | 
| 47 47 | 
             
                  it "should_receive handles a hash" do
         | 
| 48 48 | 
             
                    object.should_receive(:foobar).with(:key => "value").and_return(1)
         | 
| 49 | 
            -
                    object.foobar(:key => "value"). | 
| 49 | 
            +
                    expect(object.foobar(:key => "value")).to equal(1)
         | 
| 50 50 | 
             
                  end
         | 
| 51 51 |  | 
| 52 52 | 
             
                  it "should_receive handles an inner hash" do
         | 
| 53 53 | 
             
                    hash = {:a => {:key => "value"}}
         | 
| 54 54 | 
             
                    object.should_receive(:foobar).with(:key => "value").and_return(1)
         | 
| 55 | 
            -
                    object.foobar(hash[:a]). | 
| 55 | 
            +
                    expect(object.foobar(hash[:a])).to equal(1)
         | 
| 56 56 | 
             
                  end
         | 
| 57 57 |  | 
| 58 58 | 
             
                  it "should_receive returns a message expectation" do
         | 
| 59 | 
            -
                    object.should_receive(:foobar). | 
| 59 | 
            +
                    expect(object.should_receive(:foobar)).to be_kind_of(RSpec::Mocks::MessageExpectation)
         | 
| 60 60 | 
             
                    object.foobar
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 |  | 
| 63 63 | 
             
                  it "should_receive verifies method was called" do
         | 
| 64 64 | 
             
                    object.should_receive(:foobar).with(:test_param).and_return(1)
         | 
| 65 | 
            -
                     | 
| 65 | 
            +
                    expect {
         | 
| 66 66 | 
             
                      object.rspec_verify
         | 
| 67 | 
            -
                     | 
| 67 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 |  | 
| 70 70 | 
             
                  it "should_receive also takes a String argument" do
         | 
| @@ -74,9 +74,9 @@ module RSpec | |
| 74 74 |  | 
| 75 75 | 
             
                  it "should_not_receive also takes a String argument" do
         | 
| 76 76 | 
             
                    object.should_not_receive('foobar')
         | 
| 77 | 
            -
                     | 
| 77 | 
            +
                    expect {
         | 
| 78 78 | 
             
                      object.foobar
         | 
| 79 | 
            -
                     | 
| 79 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 80 80 | 
             
                  end
         | 
| 81 81 |  | 
| 82 82 | 
             
                  it "uses reports nil in the error message" do
         | 
| @@ -129,7 +129,7 @@ module RSpec | |
| 129 129 |  | 
| 130 130 | 
             
                  it 'works properly' do
         | 
| 131 131 | 
             
                    instance.should_receive(:proxied?).and_return(false)
         | 
| 132 | 
            -
                    instance. | 
| 132 | 
            +
                    expect(instance).not_to be_proxied
         | 
| 133 133 | 
             
                  end
         | 
| 134 134 | 
             
                end
         | 
| 135 135 |  | 
| @@ -175,19 +175,19 @@ module RSpec | |
| 175 175 |  | 
| 176 176 | 
             
                  it 'keeps public methods public' do
         | 
| 177 177 | 
             
                    object.should_receive(:public_method)
         | 
| 178 | 
            -
                    object.public_methods. | 
| 178 | 
            +
                    expect(object.public_methods).to include_method(:public_method)
         | 
| 179 179 | 
             
                    object.public_method
         | 
| 180 180 | 
             
                  end
         | 
| 181 181 |  | 
| 182 182 | 
             
                  it 'keeps private methods private' do
         | 
| 183 183 | 
             
                    object.should_receive(:private_method)
         | 
| 184 | 
            -
                    object.private_methods. | 
| 184 | 
            +
                    expect(object.private_methods).to include_method(:private_method)
         | 
| 185 185 | 
             
                    object.public_method
         | 
| 186 186 | 
             
                  end
         | 
| 187 187 |  | 
| 188 188 | 
             
                  it 'keeps protected methods protected' do
         | 
| 189 189 | 
             
                    object.should_receive(:protected_method)
         | 
| 190 | 
            -
                    object.protected_methods. | 
| 190 | 
            +
                    expect(object.protected_methods).to include_method(:protected_method)
         | 
| 191 191 | 
             
                    object.public_method
         | 
| 192 192 | 
             
                  end
         | 
| 193 193 |  | 
| @@ -32,23 +32,23 @@ module RSpec::Mocks | |
| 32 32 | 
             
                #     obj.should_receive(:msg)
         | 
| 33 33 | 
             
                #     obj.msg
         | 
| 34 34 | 
             
                #     obj.rspec_verify
         | 
| 35 | 
            -
                #      | 
| 35 | 
            +
                #     expect {
         | 
| 36 36 | 
             
                #       obj.msg
         | 
| 37 | 
            -
                #      | 
| 38 | 
            -
                # | 
| 37 | 
            +
                #     }.to raise_error(NoMethodError)
         | 
| 38 | 
            +
                #
         | 
| 39 39 | 
             
                # end
         | 
| 40 40 | 
             
                it "fails when expected message is not received" do
         | 
| 41 41 | 
             
                  obj.should_receive(:msg)
         | 
| 42 | 
            -
                   | 
| 42 | 
            +
                  expect {
         | 
| 43 43 | 
             
                    obj.rspec_verify
         | 
| 44 | 
            -
                   | 
| 44 | 
            +
                  }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 47 | 
             
                it "fails when message is received with incorrect args" do
         | 
| 48 48 | 
             
                  obj.should_receive(:msg).with(:correct_arg)
         | 
| 49 | 
            -
                   | 
| 49 | 
            +
                  expect {
         | 
| 50 50 | 
             
                    obj.msg(:incorrect_arg)
         | 
| 51 | 
            -
                   | 
| 51 | 
            +
                  }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 52 52 | 
             
                  obj.msg(:correct_arg)
         | 
| 53 53 | 
             
                end
         | 
| 54 54 |  | 
| @@ -65,30 +65,30 @@ module RSpec::Mocks | |
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 67 | 
             
                it "restores the original method if it existed" do
         | 
| 68 | 
            -
                  obj.existing_method. | 
| 68 | 
            +
                  expect(obj.existing_method).to equal(:original_value)
         | 
| 69 69 | 
             
                  obj.should_receive(:existing_method).and_return(:mock_value)
         | 
| 70 | 
            -
                  obj.existing_method. | 
| 70 | 
            +
                  expect(obj.existing_method).to equal(:mock_value)
         | 
| 71 71 | 
             
                  obj.rspec_verify
         | 
| 72 | 
            -
                  obj.existing_method. | 
| 72 | 
            +
                  expect(obj.existing_method).to equal(:original_value)
         | 
| 73 73 | 
             
                end
         | 
| 74 74 |  | 
| 75 75 | 
             
                context "with an instance method handled by method_missing" do
         | 
| 76 76 | 
             
                  it "restores the original behavior" do
         | 
| 77 | 
            -
                    obj.captured_by_method_missing. | 
| 77 | 
            +
                    expect(obj.captured_by_method_missing).to eq("response generated by method missing")
         | 
| 78 78 | 
             
                    obj.stub(:captured_by_method_missing) { "foo" }
         | 
| 79 | 
            -
                    obj.captured_by_method_missing. | 
| 79 | 
            +
                    expect(obj.captured_by_method_missing).to eq("foo")
         | 
| 80 80 | 
             
                    obj.rspec_reset
         | 
| 81 | 
            -
                    obj.captured_by_method_missing. | 
| 81 | 
            +
                    expect(obj.captured_by_method_missing).to eq("response generated by method missing")
         | 
| 82 82 | 
             
                  end
         | 
| 83 83 | 
             
                end
         | 
| 84 84 |  | 
| 85 | 
            -
                context "with a class method handled by method_missing" do | 
| 85 | 
            +
                context "with a class method handled by method_missing" do
         | 
| 86 86 | 
             
                  it "restores the original behavior" do
         | 
| 87 | 
            -
                    klass.captured_by_method_missing. | 
| 87 | 
            +
                    expect(klass.captured_by_method_missing).to eq("response generated by method missing")
         | 
| 88 88 | 
             
                    klass.stub(:captured_by_method_missing) { "foo" }
         | 
| 89 | 
            -
                    klass.captured_by_method_missing. | 
| 89 | 
            +
                    expect(klass.captured_by_method_missing).to eq("foo")
         | 
| 90 90 | 
             
                    klass.rspec_reset
         | 
| 91 | 
            -
                    klass.captured_by_method_missing. | 
| 91 | 
            +
                    expect(klass.captured_by_method_missing).to eq("response generated by method missing")
         | 
| 92 92 | 
             
                  end
         | 
| 93 93 | 
             
                end
         | 
| 94 94 | 
             
              end
         | 
| @@ -87,11 +87,11 @@ module RSpec | |
| 87 87 | 
             
                  context "handling block matchers" do
         | 
| 88 88 | 
             
                    it "matches arguments against RSpec expectations" do
         | 
| 89 89 | 
             
                      @double.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
         | 
| 90 | 
            -
                        arg1. | 
| 91 | 
            -
                        arg2. | 
| 92 | 
            -
                        arg2. | 
| 93 | 
            -
                        arr.map {|i| i * 2}. | 
| 94 | 
            -
                        rest. | 
| 90 | 
            +
                        expect(arg1).to eq 5
         | 
| 91 | 
            +
                        expect(arg2).to have_at_least(3).characters
         | 
| 92 | 
            +
                        expect(arg2).to have_at_most(10).characters
         | 
| 93 | 
            +
                        expect(arr.map {|i| i * 2}).to eq [2,4,6]
         | 
| 94 | 
            +
                        expect(rest).to eq [:fee, "fi", 4]
         | 
| 95 95 | 
             
                      }
         | 
| 96 96 | 
             
                      @double.random_call 5, "hello", [1,2,3], :fee, "fi", 4
         | 
| 97 97 | 
             
                    end
         | 
| @@ -100,7 +100,7 @@ module RSpec | |
| 100 100 | 
             
                      eval_count = 0
         | 
| 101 101 | 
             
                      @double.should_receive(:msg).with {|a| eval_count += 1}
         | 
| 102 102 | 
             
                      @double.msg(:ignore)
         | 
| 103 | 
            -
                      eval_count. | 
| 103 | 
            +
                      expect(eval_count).to eq(1)
         | 
| 104 104 | 
             
                    end
         | 
| 105 105 | 
             
                  end
         | 
| 106 106 |  | 
| @@ -11,9 +11,9 @@ module RSpec | |
| 11 11 | 
             
                    @double.should_receive(:do_something).exactly(3).times
         | 
| 12 12 | 
             
                    @double.do_something
         | 
| 13 13 | 
             
                    @double.do_something
         | 
| 14 | 
            -
                     | 
| 14 | 
            +
                    expect {
         | 
| 15 15 | 
             
                      @double.rspec_verify
         | 
| 16 | 
            -
                     | 
| 16 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 17 17 | 
             
                  end
         | 
| 18 18 |  | 
| 19 19 | 
             
                  it "fails fast when exactly n times method is called more than n times" do
         | 
| @@ -21,16 +21,16 @@ module RSpec | |
| 21 21 | 
             
                    @double.do_something
         | 
| 22 22 | 
             
                    @double.do_something
         | 
| 23 23 | 
             
                    @double.do_something
         | 
| 24 | 
            -
                     | 
| 24 | 
            +
                    expect {
         | 
| 25 25 | 
             
                      @double.do_something
         | 
| 26 | 
            -
                     | 
| 26 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 29 | 
             
                  it "fails when exactly n times method is never called" do
         | 
| 30 30 | 
             
                    @double.should_receive(:do_something).exactly(3).times
         | 
| 31 | 
            -
                     | 
| 31 | 
            +
                    expect {
         | 
| 32 32 | 
             
                      @double.rspec_verify
         | 
| 33 | 
            -
                     | 
| 33 | 
            +
                    }.to raise_error(RSpec::Mocks::MockExpectationError)
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| 36 36 | 
             
                  it "passes if exactly n times method is called exactly n times" do
         | 
| @@ -43,7 +43,7 @@ module RSpec | |
| 43 43 |  | 
| 44 44 | 
             
                  it "returns the value given by a block when the exactly once method is called" do
         | 
| 45 45 | 
             
                    @double.should_receive(:to_s).exactly(:once) { "testing" }
         | 
| 46 | 
            -
                    @double.to_s. | 
| 46 | 
            +
                    expect(@double.to_s).to eq "testing"
         | 
| 47 47 | 
             
                    @double.rspec_verify
         | 
| 48 48 | 
             
                  end
         | 
| 49 49 |  | 
| @@ -7,19 +7,19 @@ module RSpec | |
| 7 7 | 
             
                    @mock = double("mock").as_null_object
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 | 
             
                  it "answers false for received_message? when no messages received" do
         | 
| 10 | 
            -
                    @mock.received_message?(:message). | 
| 10 | 
            +
                    expect(@mock.received_message?(:message)).to be_false
         | 
| 11 11 | 
             
                  end
         | 
| 12 12 | 
             
                  it "answers true for received_message? when message received" do
         | 
| 13 13 | 
             
                    @mock.message
         | 
| 14 | 
            -
                    @mock.received_message?(:message). | 
| 14 | 
            +
                    expect(@mock.received_message?(:message)).to be_true
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 | 
             
                  it "answers true for received_message? when message received with correct args" do
         | 
| 17 17 | 
             
                    @mock.message 1,2,3
         | 
| 18 | 
            -
                    @mock.received_message?(:message, 1,2,3). | 
| 18 | 
            +
                    expect(@mock.received_message?(:message, 1,2,3)).to be_true
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 | 
             
                  it "answers false for received_message? when message received with incorrect args" do
         | 
| 21 21 | 
             
                    @mock.message 1,2,3
         | 
| 22 | 
            -
                    @mock.received_message?(:message, 1,2). | 
| 22 | 
            +
                    expect(@mock.received_message?(:message, 1,2)).to be_false
         | 
| 23 23 | 
             
                  end
         | 
| 24 24 | 
             
                end
         | 
| 25 25 | 
             
              end
         |