Sha256: db5acba2cb79bb3d27dc96f20ce007c759489a7fadf84b711c480b048111c62f

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe StorageRoom::Array do
  context "Class" do
    context "Configuration" do
  
    end
    
    context "Methods" do
      
    end
  end
  
  context "Instance" do
    before(:each) do
      @array = StorageRoom::Array.new
    end
    
    describe "#initialize" do
      it "should set resources" do
        @array.resources.should == []
      end
    end
    
    describe "#set_from_api" do
      before(:each) do
        @hash = {'@page' => 1, 'resources' => [{'one' => 1, '@type' => 'Guidebook'}, {'two' => 2, '@type' => 'Guidebook'}]}
        @array.set_from_api(@hash)
      end
      
      it "should set meta data" do
        @array['@page'].should == 1
      end
      
      it "should set resources" do
        @array.resources.should have(2).items
        @array.resources[0].should be_an_instance_of(Guidebook)
        @array.resources[0][:one].should == 1
        @array.resources[1].should be_an_instance_of(Guidebook)        
        @array.resources[1][:two].should == 2
      end
    end
    
    describe "#reset!" do
      it "should reset" do
        @array.reset!
        @array.resources.should == []
      end
    end
    
    describe "#load_next_page!" do
      it "should not load when not present" do
        @array.load_next_page!.should be_false
      end
      
      it "should load when present" do
        @array[:@next_page_url] = "url"
        @array.stub(:reload)
        @array.should_receive(:reload)
        @array.load_next_page!.should be_true
      end
    end
    
    describe "#load_previous_page!" do
      it "should not load when not present" do
        @array.load_previous_page!.should be_false
      end
      
      it "should load when present" do
        @array[:@previous_page_url] = "url"
        @array.stub(:reload)
        @array.should_receive(:reload)
        @array.load_previous_page!.should be_true
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storage_room-0.2.1 spec/storage_room/array_spec.rb
storage_room-0.2.0 spec/storage_room/array_spec.rb
storage_room-0.1.4 spec/storage_room/array_spec.rb
storage_room-0.1.3 spec/storage_room/array_spec.rb
storage_room-0.1.2 spec/storage_room/array_spec.rb