adding all of botlist, initial add
[botlist.git] / openbotlist / WEB-INF / lib / ruby / rspec / spec / spec / mocks / options_hash_spec.rb
blob0bfab26d756551f7f85a8e268e7a4ccc9f79c7c9
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
3 module Spec
4   module Mocks
5     describe "calling :should_receive with an options hash" do
6       it_should_behave_like "sandboxed rspec_options"
7       attr_reader :reporter, :example_group
8       before do
9         @reporter = ::Spec::Runner::Reporter.new(options)
10         @example_group = Class.new(::Spec::Example::ExampleGroup) do
11           plugin_mock_framework
12           describe("Some Examples")
13         end
14         reporter.add_example_group example_group
15       end
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")
21           mock.rspec_verify
22         end
23         example = example_group.new(example_definition)
24         
25         reporter.should_receive(:example_finished) do |spec, error|
26           error.backtrace.detect {|line| line =~ /\/path\/to\/blah.ext:37/}.should_not be_nil
27         end
28         example.execute(options, {})
29       end
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")
35           mock.rspec_verify
36         end
37         example = @example_group.new(example_definition)
38         @reporter.should_receive(:example_finished) do |spec, error|
39           error.message.should == "recebi nada"
40         end
41         example.execute(@options, {})
42       end
43     end
44   end
45 end