Sha256: 6b45b09d5fefa8331a1a45782b7b99999ac1ccbbc15cb9dd554934e6d6de0e87

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

RSpec.describe Mongoid::Matchers::HaveTimestamps do
  context 'when model includes Mongoid::Timestamps' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps
      end
    end

    it { is_expected.to have_timestamps }
  end

  context 'when model includes Mongoid::Timestamps::Short' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps::Short
      end
    end

    it { is_expected.to have_timestamps.shortened }
  end

  context 'when model includes Mongoid::Timestamps::Updated' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps::Updated
      end
    end

    it { is_expected.to have_timestamps.for(:updating) }
  end

  context 'when model includes Mongoid::Timestamps::Updated::Short' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps::Updated::Short
      end
    end

    it { is_expected.to have_timestamps.for(:updating).shortened }
    it { is_expected.to have_timestamps.shortened.for(:updating) }
  end

  context 'when model includes Mongoid::Timestamps::Created' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps::Created
      end
    end

    it { is_expected.to have_timestamps.for(:creating) }
  end

  context 'when model includes Mongoid::Timestamps::Created::Short' do
    subject do
      Class.new do
        include Mongoid::Document
        include Mongoid::Timestamps::Created::Short
      end
    end

    it { is_expected.to have_timestamps.for(:creating).shortened }
    it { is_expected.to have_timestamps.shortened.for(:creating) }
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mongoid-rspec-4.1.0 spec/unit/have_timestamps_spec.rb
mongoid-rspec-4.0.1 spec/unit/have_timestamps_spec.rb
mongoid-rspec-4.0.0 spec/unit/have_timestamps_spec.rb
mongoid-spec-4.0.1 spec/unit/have_timestamps_spec.rb