Sha256: b4c5a45d2a6b8f331c95d2fdb2f9f0a32c27fbe882844093738d011778bcd64d

Contents?: true

Size: 832 Bytes

Versions: 16

Compression:

Stored size: 832 Bytes

Contents

require "spec_helper"

describe Shamu::Services::LazyAssociation do
  it "calls block to look up association" do
    assoc = double
    expect( assoc ).to receive( :label )
    lazy = Shamu::Services::LazyAssociation.new( 1 ) { assoc }
    lazy.label
  end

  it "delegates ==" do
    assoc = double
    lazy = Shamu::Services::LazyAssociation.new( 1 ) { assoc }
    expect( lazy ).to eq assoc
  end

  it "does not delegate id" do
    assoc = double
    expect( assoc ).not_to receive( :id )
    lazy = Shamu::Services::LazyAssociation.new( 1 ) { assoc }
    lazy.id
  end

  it "has the same class as original object" do
    assoc = double
    expect( assoc ).to receive( :to_entity ).and_return assoc
    lazy = Shamu::Services::LazyAssociation.new( 1 ) { assoc }

    expect( lazy.to_entity ).to be_kind_of assoc.class
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shamu-0.0.21 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.20 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.19 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.18 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.17 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.15 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.14 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.13 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.11 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.9 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.8 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.7 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.5 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.4 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.3 spec/lib/shamu/services/lazy_association_spec.rb
shamu-0.0.2 spec/lib/shamu/services/lazy_association_spec.rb