Sha256: e85663d026b01b62d7f4ba0c190491582e574ddc8405e18fa8e7181a175dc6a1

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Session::Relation, '#dirty?' do
  subject { users.dirty?(user) }

  include_context 'Session::Relation'

  context 'with a transient object' do
    let(:user) { users.new }

    it { should be(true) }
  end

  context 'when persisted object was changed' do
    before do
      user.name = 'John Doe'
    end

    it { should be(true) }
  end

  context 'when persisted object was not changed' do
    it { should be(false) }
  end

  context 'when object is not tracked' do
    let(:user) { model.new(id: 3, name: 'Unknown') }

    specify do
      expect { subject }.to raise_error(
        Session::ObjectNotTrackedError,
        "Tracker doesn't include #{user.inspect}"
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-session-0.1.1 spec/unit/rom/session/relation/dirty_predicate_spec.rb
rom-session-0.1.0 spec/unit/rom/session/relation/dirty_predicate_spec.rb