Sha256: 27d7fc00969bd53e6180032cb6a778bd05814091b923c1e0daf39f11c9179571

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require_fixtures
 
Aqua.set_storage_engine('CouchDB') # to initialize CouchDB
CouchDB = Aqua::Store::CouchDB unless defined?( CouchDB )

describe Aqua::Stub do
  before(:each) do 
    @params = {
      :id => 'my_great_id',
      :class => 'Gerbilmiester',
      :methods => {
        :gerbil => true,
        :bacon => 'chunky'
      }
    }
    @stub = Aqua::Stub.new( @params )
  end  
    
  describe 'initialization' do
    it 'should initialize delegate with a TempStub' do
      delegate = @stub.instance_eval( "__getobj__" )
      delegate.class.should == Aqua::TempStub
    end
    
    it 'should initialize the delegate_id' do
      @stub.instance_eval('delegate_id').should == 'my_great_id'
    end
      
    it 'should initialize the delegate_class' do  
      @stub.instance_eval('delegate_class').should == 'Gerbilmiester'
    end   
  end
  
  describe 'delegation' do 
    it 'should return correct values for initialized methods' do 
      @stub.gerbil.should == true
      @stub.bacon.should == 'chunky'
    end
    
    it 'should try to retrieve an object if an unspecified method is called' do 
      Gerbilmiester.should_receive(:load).and_return( Gerbilmiester.new )
      @stub.herd
    end 
    
    it 'should return correct values for new delegate' do 
      Gerbilmiester.should_receive(:load).and_return( Gerbilmiester.new )
      @stub.herd.should == 'Yah, yah, little gerbil'
    end   
  end     
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aqua-0.1.6 spec/object/stub_spec.rb