Sha256: 5f5829053efd4271201059106b71b2c32ccb3efe3d0174d3cb4ec76faf952d50
Contents?: true
Size: 1.36 KB
Versions: 12
Compression:
Stored size: 1.36 KB
Contents
require "spec_helper" describe "a double declaration with a block handed to:" do describe "should_receive" do it "returns the value of executing the block" do obj = Object.new obj.should_receive(:foo) { 'bar' } obj.foo.should eq('bar') end it "works when a multi-return stub has already been set" do obj = Object.new return_value = Object.new obj.stub(:foo).and_return(return_value, nil) obj.should_receive(:foo) { return_value } obj.foo.should be(return_value) end end describe "stub" do it "returns the value of executing the block" do obj = Object.new obj.stub(:foo) { 'bar' } obj.foo.should eq('bar') end end describe "with" do it "returns the value of executing the block" do obj = Object.new obj.stub(:foo).with('baz') { 'bar' } obj.foo('baz').should eq('bar') end end %w[once twice any_number_of_times ordered and_return].each do |method| describe method do it "returns the value of executing the block" do obj = Object.new obj.stub(:foo).send(method) { 'bar' } obj.foo.should eq('bar') end end end describe "times" do it "returns the value of executing the block" do obj = Object.new obj.stub(:foo).at_least(1).times { 'bar' } obj.foo('baz').should eq('bar') end end end
Version data entries
12 entries across 12 versions & 5 rubygems