Sha256: 522b65a972f245a5326c96a3ce246347fba0fdaad3725433bb4b7b1f83290814

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require 'spec_helper'
require 'support/time_machine/structure'

describe ChronoModel::TimeMachine do
  include ChronoTest::TimeMachine::Helpers

  adapter.create_table 'plains' do |t|
    t.string :foo
  end

  class ::Plain < ActiveRecord::Base
  end

  describe '.chrono?' do
    subject { model.chrono? }

    context 'on a temporal model' do
      let(:model) { Foo }
      it { is_expected.to be(true) }
    end

    context 'on a plain model' do
      let(:model) { Plain }
      it { is_expected.to be(false) }
    end
  end

  describe '.history?' do
    subject { model.history? }

    context 'on a temporal parent model' do
      let(:model) { Foo }
      it { is_expected.to be(false) }
    end

    context 'on a temporal history model' do
      let(:model) { Foo::History }
      it { is_expected.to be(true) }
    end

    context 'on a plain model' do
      let(:model) { Plain }
      it { expect { subject }.to raise_error(NoMethodError) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chrono_model-1.2.2 spec/chrono_model/time_machine/model_identification_spec.rb
chrono_model-1.2.1 spec/chrono_model/time_machine/model_identification_spec.rb