Sha256: bd78b3de5d4acb838dbc070f11d0ad151567435aaf7332940e60d71d4925e3a1

Contents?: true

Size: 919 Bytes

Versions: 14

Compression:

Stored size: 919 Bytes

Contents

require 'helper'

describe Toy::Store do
  uses_constants('User')

  describe "including" do
    it "adds model naming" do
      model_name = User.model_name
      model_name.should           == 'User'
      model_name.singular.should  == 'user'
      model_name.plural.should    == 'users'
    end

    it "adds to_model" do
      user = User.new
      user.to_model.should == user
    end

    describe "#to_key" do
      it "returns [id] if persisted" do
        user = User.create
        user.to_key.should == [user.id]
      end

      it "returns nil if not persisted" do
        User.new.to_key.should be_nil
      end
    end

    describe "#to_param" do
      it "returns key joined by - if to_key present" do
        user = User.create
        user.to_param.should == user.to_key.join('-')
      end

      it "returns nil if to_key nil" do
        User.new.to_param.should be_nil
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
toystore-0.9.0 spec/toy/store_spec.rb
toystore-0.8.3 spec/toy/store_spec.rb
toystore-0.8.2 spec/toy/store_spec.rb
toystore-0.8.1 spec/toy/store_spec.rb
toystore-0.8.0 spec/toy/store_spec.rb
toystore-0.7.0 spec/toy/store_spec.rb
toystore-0.6.6 spec/toy/store_spec.rb
toystore-0.6.5 spec/toy/store_spec.rb
toystore-0.6.4 spec/toy/store_spec.rb
toystore-0.6.3 spec/toy/store_spec.rb
toystore-0.6.2 spec/toy/store_spec.rb
toystore-0.6.1 spec/toy/store_spec.rb
toystore-0.6 spec/toy/store_spec.rb
toystore-0.5 spec/toy/store_spec.rb