Sha256: 9d57bcf37cab234c29576fb62e34177a1050e378477a35569e33938f48da6a95

Contents?: true

Size: 594 Bytes

Versions: 29

Compression:

Stored size: 594 Bytes

Contents

require 'spec_helper'

describe NinjaModel::Identity do
  class IdentityModel < NinjaModel::Base
    attribute :primary, :integer, :primary_key => true
  end
  before {
    @obj = IdentityModel.new
    @obj.primary = 123
    @obj
  }
  subject { @obj }

  context 'when persisted' do
    before { @obj.stubs(:persisted?).returns(true) }
    its(:to_param) { should eql('123') }
    its(:to_key) { should eql([123]) }
  end

  context 'when not persisted' do
    before { @obj.stubs(:persisted?).returns(false) }
    its(:to_param) { should be_nil }
    its(:to_key) { should be_nil }
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ninja-model-1.0.5 spec/lib/ninja_model/identity_spec.rb
ninja-model-1.0.4 spec/lib/ninja_model/identity_spec.rb
ninja-model-1.0.3 spec/lib/ninja_model/identity_spec.rb
ninja-model-1.0.2 spec/lib/ninja_model/identity_spec.rb
ninja-model-1.0.1 spec/lib/ninja_model/identity_spec.rb
ninja-model-1.0.0 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.6 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.5 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.4 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.3 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.2 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.1 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.9.0 spec/lib/ninja_model/identity_spec.rb
ninja-model-0.8.1 spec/ninja_model/identity_spec.rb
ninja-model-0.8.0 spec/ninja_model/identity_spec.rb
ninja-model-0.7.3 spec/ninja_model/identity_spec.rb
ninja-model-0.7.2 spec/ninja_model/identity_spec.rb
ninja-model-0.7.1 spec/ninja_model/identity_spec.rb
ninja-model-0.7.0 spec/ninja_model/identity_spec.rb
ninja-model-0.6.2 spec/ninja_model/identity_spec.rb