Sha256: d8048f7bda979ea4e59daeb91508a73fdfe1c9b64267a3ae77d4f9fc2992ce4e

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Session::State do
  fake(:object)
  fake(:mapper)
  fake(:relation)

  describe '#transient?' do
    context 'with transient state' do
      subject { Session::State::Transient.new(object, mapper) }

      it { should be_transient }
    end

    context 'with a non-transient state' do
      subject { Session::State::Persisted.new(object, mapper) }

      it { should_not be_transient }
    end
  end

  describe '#persisted?' do
    context 'with a persisted state' do
      subject { Session::State::Persisted.new(object, mapper) }

      it { should be_persisted }
    end

    context 'with a non-persisted state' do
      subject { Session::State::Transient.new(object, mapper) }

      it { should_not be_persisted }
    end
  end

  describe '#created?' do
    context 'with a created state' do
      subject { Session::State::Created.new(object, mapper, relation) }

      it { should be_created }
    end

    context 'with a non-created state' do
      subject { Session::State::Transient.new(object, mapper) }

      it { should_not be_created }
    end
  end

  describe '#updated?' do
    context 'with an updated state' do
      subject { Session::State::Updated.new(object, [], relation) }

      it { should be_updated }
    end

    context 'with a non-updated state' do
      subject { Session::State::Transient.new(object, mapper) }

      it { should_not be_updated }
    end
  end

  describe '#deleted?' do
    context 'with a deleted state' do
      subject { Session::State::Deleted.new(object, mapper, relation) }

      it { should be_deleted }
    end

    context 'with a non-updated state' do
      subject { Session::State::Transient.new(object, mapper) }

      it { should_not be_deleted }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.2.0 spec/unit/rom/session/state_spec.rb