Sha256: 4e4e77f221caebfbe6220a0979aa5a45c547e8a42c6e24617b9c06b11405a8f7

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

module Satchel
  describe Activity do
    subject { Satchel::Activity.new }
    let(:object) { PersistenceLayer.new }

    describe 'with persisted object' do
      it 'should marshal the subject' do
        subject.subject = object
        expect(subject.subject).to eq(object)
      end

      it 'should capture the subject id' do
        subject.subject = object
        expect(subject.subject_id).to eq(object.to_param)
      end

      it 'should capture the subject type' do
        subject.subject = object
        expect(subject.subject_type).to eq(object.class.to_s)
      end
    end

    describe 'with a non persisted object' do

      it 'raise exception if the object is not persisted' do
        def object.persisted?; false; end
        expect {
          subject.subject = object
        }.to raise_error(Satchel::UnpersistedSubjectError)
      end

      it 'raise exception if the object does not respond to persisted' do
        expect {
          subject.subject = 2
        }.to raise_error(NoMethodError)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
satchel-0.0.2 spec/models/satchel/activity_spec.rb
satchel-0.0.1 spec/models/satchel/activity_spec.rb