1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe "calling :should_receive with an options hash" do
6 it_should_behave_like "sandboxed rspec_options"
7 attr_reader :reporter, :example_group
9 @reporter = ::Spec::Runner::Reporter.new(options)
10 @example_group = Class.new(::Spec::Example::ExampleGroup) do
12 describe("Some Examples")
14 reporter.add_example_group example_group
17 it "should report the file and line submitted with :expected_from" do
18 example_definition = example_group.it "spec" do
19 mock = Spec::Mocks::Mock.new("a mock")
20 mock.should_receive(:message, :expected_from => "/path/to/blah.ext:37")
23 example = example_group.new(example_definition)
25 reporter.should_receive(:example_finished) do |spec, error|
26 error.backtrace.detect {|line| line =~ /\/path\/to\/blah.ext:37/}.should_not be_nil
28 example.execute(options, {})
31 it "should use the message supplied with :message" do
32 example_definition = @example_group.it "spec" do
33 mock = Spec::Mocks::Mock.new("a mock")
34 mock.should_receive(:message, :message => "recebi nada")
37 example = @example_group.new(example_definition)
38 @reporter.should_receive(:example_finished) do |spec, error|
39 error.message.should == "recebi nada"
41 example.execute(@options, {})