Sha256: b55d5a8c6f58a051515c392a24b8c629f4ba37d5819d23e9e9de41047cb68b9c
Contents?: true
Size: 1.1 KB
Versions: 194
Compression:
Stored size: 1.1 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 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
194 entries across 140 versions & 13 rubygems