Sha256: 34706c2a67a6e705e33555e139992df5cc52fd46b7d3c856dbf99e979fa46303

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

require 'orangutan'

module Orangutan
  describe Chantek, 'creating recursive ruby stubs' do
    before do
      @o = Chantek.new
      @foo = @o.stub :foo, :recursive => true
    end
    
    it "should return the same object when generating a stub for the same name" do
      @foo.__id__.should. == @o.stub(:foo).__id__
    end
    
    it "should return nil instead of new stub when instructed to" do
      @o.when(:foo).receives(:bar).return(nil)
      @foo.bar.should == nil
    end

    it "should return new stubs from each method call" do
      bar = @foo.bar
      baz = bar.baz
      @o.calls[0].should == Call.new(:foo, :bar,[])
      @o.calls[1].should == Call.new(:"foo/bar", :baz,[])
    end

    it "should create recursive stubs" do
      @foo.a.b.c
      @o.stubs.keys.should == [:foo, :"foo/a", :"foo/a/b", :"foo/a/b/c"]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
orangutan-0.0.4 spec/spec_chantek_recurse.rb
orangutan-0.0.3 spec/spec_chantek_recurse.rb