Sha256: 02641832e423feb1b5d5c322aaa80b9c1ddb107a9c74c934f0fb12bf645cee62

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

require 'spec_helper'

class TimeStampedModel
  include Id::Model
  include Id::Timestamps

  field :foo
  field :bar
end

module Id
  describe Timestamps do

    let (:model) { TimeStampedModel.new(foo: 999, bar: 666) }

    it 'should have a created_at date' do
      model.created_at.should be_a Time
    end

    it 'should have an updated_at date' do
      model.updated_at.should be_a Time
    end

    it 'should update the updated at when set is called' do
      updated = model.set(foo: 123)
      expect(updated.created_at).to be < updated.updated_at
    end

    it 'should update the updated at when unset is called' do
      updated = model.unset(:foo)
      expect(updated.created_at).to be < updated.updated_at
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
id-0.0.9 spec/lib/id/timestamps_spec.rb
id-0.0.8 spec/lib/id/timestamps_spec.rb