Sha256: d2a478098bb47ad1f9a797449936b8a7b55a179eb1d22715071b76c0ee35df9b
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' module DevelopWithPassion module Fakes describe ArgBehaviour do class AnArg attr_accessor :called_args,:args def initialize @times_called = 0 end end let(:sut){AnArg.new} before (:each) do sut.send(:extend,ArgBehaviour) end context "when a return value is specified" do before (:each) do sut.and_return(2) end it "should store the return value to be returned during invocation" do sut.return_value.should == 2 end end context "when handling an invocation" do before (:each) do sut.capture_args(2) end it "should increment the number of times it was called" do sut.times_called.should == 1 end it "should store the arguments it was called with" do sut.called_args.should == [2] end end context "when matching a set of arguments" do before (:each) do sut.args = [2] end it "should match if its own set of arguments are the same" do sut.matches?(2).should be_true sut.matches?(3).should be_false end end context "when determining whether it was called with a set of arguments" do before (:each) do sut.called_args = [2] end it "should match if the arguments are the same as the arguments it was invoked with" do sut.was_called_with?(2).should be_true sut.was_called_with?(3).should be_false end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems