Sha256: 7a2216441603e0e599aa0ad1b19b2cf35e50b75c026792cbc451677c81782a6b

Contents?: true

Size: 683 Bytes

Versions: 5

Compression:

Stored size: 683 Bytes

Contents

require 'spec_helper'

class TimeStampedModel
  include Structural::Model
  include Structural::Timestamps

  field :foo
  field :bar
end

module Structural
  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 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

5 entries across 5 versions & 1 rubygems

Version Path
structural-0.2.0 spec/lib/structural/timestamps_spec.rb
structural-0.1.0 spec/lib/structural/timestamps_spec.rb
structural-0.0.3 spec/lib/structural/timestamps_spec.rb
structural-0.0.2 spec/lib/structural/timestamps_spec.rb
structural-0.0.1 spec/lib/structural/timestamps_spec.rb