Sha256: 1d1a7692ba717cb9c943a35a66f81eba1a5627f7a5fd04a00df1076135bc1507

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

module RSpec
  module Mocks
    describe "calling :should_receive with an options hash" do
      it "reports the file and line submitted with :expected_from" do
        begin
          mock = RSpec::Mocks::Mock.new("a mock")
          mock.should_receive(:message, :expected_from => "/path/to/blah.ext:37")
          mock.rspec_verify
        rescue Exception => e
        ensure
          expect(e.backtrace.to_s).to match /\/path\/to\/blah.ext:37/m
        end
      end

      it "uses the message supplied with :message" do
        expect {
          m = RSpec::Mocks::Mock.new("a mock")
          m.should_receive(:message, :message => "recebi nada")
          m.rspec_verify
        }.to raise_error("recebi nada")
      end

      it "uses the message supplied with :message after a similar stub" do
        expect {
          m = RSpec::Mocks::Mock.new("a mock")
          m.stub(:message)
          m.should_receive(:message, :message => "from mock")
          m.rspec_verify
        }.to raise_error("from mock")
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 6 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/spec/rspec/mocks/options_hash_spec.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/options_hash_spec.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/options_hash_spec.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/options_hash_spec.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/options_hash_spec.rb
rspec-mocks-2.13.1 spec/rspec/mocks/options_hash_spec.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/spec/rspec/mocks/options_hash_spec.rb
rspec-mocks-2.13.0 spec/rspec/mocks/options_hash_spec.rb
remq-0.0.4 vendor/bundle/gems/rspec-mocks-2.12.2/spec/rspec/mocks/options_hash_spec.rb
remq-0.0.3 vendor/bundle/gems/rspec-mocks-2.12.2/spec/rspec/mocks/options_hash_spec.rb
rspec-mocks-2.12.2 spec/rspec/mocks/options_hash_spec.rb