Sha256: 31469245e5548aab01d3ccca1baa1644a2503c8db535c1ba05f5944bba89dc20

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

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

describe "Identity Map" do
  before(:each) do
    gsfn = {:id => 4, :domain => 'getsatisfaction'}

    # Single record response w/ gsfn
    FakeWeb.register_uri(
      :get,
      "http://#{@api_host}/companies/4.json",
      :body => gsfn.to_json
    )

    # Collection response that includes gsfn
    FakeWeb.register_uri(
      :get,
      "http://#{@api_host}/companies.json?q=satisfaction&page=1&limit=10",
      :body => {"total" => 1, "data" => [gsfn]}.to_json
    )
  end

  it "should work single instances" do
    c1 = @sfn.companies.get(4)
    c2 = @sfn.companies.get(4)
    
    c1.object_id.should == c2.object_id
  end
  
  it "should load one if the other gets loaded" do
    c1 = @sfn.companies.get(4)
    c2 = @sfn.companies.get(4)
    c2.should_not be_loaded
    
    c1.load
  
    c2.should be_loaded
    c2.domain.should == 'getsatisfaction'
  end
  
  it "should work with pages too" do
    c1 = @sfn.companies.get(4)
    c2 = @sfn.companies.page(1, :q => 'satisfaction').first
    
    c1.object_id.should == c2.object_id
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-satisfaction-0.6.7 spec/satisfaction/identity_map_spec.rb
ruby-satisfaction-0.6.5 spec/satisfaction/identity_map_spec.rb
ruby-satisfaction-0.6.4 spec/satisfaction/identity_map_spec.rb
ruby-satisfaction-0.6.3 spec/satisfaction/identity_map_spec.rb
ruby-satisfaction-0.6.2 spec/satisfaction/identity_map_spec.rb
ruby-satisfaction-0.6.1 spec/satisfaction/identity_map_spec.rb