Sha256: ff483947d02f487270e2a58a306c3fbaec52043f341512acea6a6806ff045a3a

Contents?: true

Size: 1.51 KB

Versions: 25

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

class Post < StorageRoom::Entry
  key :name
end

describe StorageRoom::Proxy do
  before(:each) do
    @hash_unloaded = {'@type' => 'Post', 'url' => 'URL'}
    @object_unloaded = Post.new
    
    @hash_loaded = {'@type' => 'Post', '@url' => 'URL', 'name' => 'NAME'}
    @object_loaded = Post.new_from_response_data(@hash_loaded)
    
    @proxy_unloaded = StorageRoom::Proxy.new(@object_unloaded)
    @proxy_loaded = StorageRoom::Proxy.new(@object_loaded)
  end
  
  context "Methods" do
    describe "#proxy" do
      it "should return true" do
        @proxy_unloaded.proxy?.should be_true
        @proxy_loaded.proxy?.should be_true
      end
    end
    
    describe "#response_data" do
      it "should return from object" do
        @proxy_unloaded.response_data.should == {}
        @proxy_loaded.response_data.should == @object_loaded.response_data
      end
    end
    
    describe "#loaded?" do
      it "should return false" do
        @proxy_unloaded.loaded?.should be_false
      end
      
      it "should return true" do
        @proxy_loaded.loaded?.should be_true
      end
    end
    
    describe "#method_missing" do
      it "should forward to object" do
        @proxy_loaded.name.should == 'NAME'
      end
      
      it "should reload if missing" do
        @object_unloaded.response_data = @hash_unloaded
        @object_unloaded.stub(:reload)
        @object_unloaded.should_receive(:reload).with(@hash_unloaded['url'], {})
        
        @proxy_unloaded.name
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
storage_room-0.3.24 spec/storage_room/proxy_spec.rb
storage_room-0.3.23 spec/storage_room/proxy_spec.rb
storage_room-0.3.22 spec/storage_room/proxy_spec.rb
storage_room-0.3.21 spec/storage_room/proxy_spec.rb
storage_room-0.3.20 spec/storage_room/proxy_spec.rb
storage_room-0.3.19 spec/storage_room/proxy_spec.rb
storage_room-0.3.18 spec/storage_room/proxy_spec.rb
storage_room-0.3.17 spec/storage_room/proxy_spec.rb
storage_room-0.3.16 spec/storage_room/proxy_spec.rb
storage_room-0.3.15 spec/storage_room/proxy_spec.rb
storage_room-0.3.14 spec/storage_room/proxy_spec.rb
storage_room-0.3.13 spec/storage_room/proxy_spec.rb
storage_room-0.3.12 spec/storage_room/proxy_spec.rb
storage_room-0.3.11 spec/storage_room/proxy_spec.rb
storage_room-0.3.10 spec/storage_room/proxy_spec.rb
storage_room-0.3.9 spec/storage_room/proxy_spec.rb
storage_room-0.3.8 spec/storage_room/proxy_spec.rb
storage_room-0.3.7 spec/storage_room/proxy_spec.rb
storage_room-0.3.6 spec/storage_room/proxy_spec.rb
storage_room-0.3.5 spec/storage_room/proxy_spec.rb