Sha256: 9033021bc448a93690c169a1c58343ed1c228bf9e5413cde37aee04409dc2ef9

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'
require 'orm/models/test_class'

describe MassiveRecord::ORM::Persistence::Operations do
  let(:options) { {:this => 'hash', :has => 'options'} }

  describe "factory method" do
    context "table record" do
      let(:record) { TestClass.new }

      [:insert, :update, :destroy, :atomic_operation, :reload].each do |method|
        describe "##{method}" do
          subject { described_class.send(method, record, options) }

          its(:record) { should eq record }
          its(:klass) { should eq record.class }
          its(:options) { should eq options }

          it "is an instance of Persistence::Operations::#{method.to_s.classify}" do
            klass = "MassiveRecord::ORM::Persistence::Operations::#{method.to_s.classify}".constantize
            should be_instance_of klass
          end

          it "is possible to suppress" do
             MassiveRecord::ORM::Persistence::Operations.suppress do
               subject.should be_instance_of MassiveRecord::ORM::Persistence::Operations::Suppress
             end
          end
        end
      end
    end

    context "embedded record" do
      let(:record) { Address.new }

      [:insert, :update, :destroy, :reload].each do |method|
        describe "##{method}" do
          subject { described_class.send(method, record, options) }

          its(:record) { should eq record }
          its(:klass) { should eq record.class }
          its(:options) { should eq options }

          it "is an instance of Persistence::Operations::#{method.to_s.classify}" do
            klass = "MassiveRecord::ORM::Persistence::Operations::Embedded::#{method.to_s.classify}".constantize
            should be_instance_of klass
          end

          it "is possible to suppress" do
             MassiveRecord::ORM::Persistence::Operations.suppress do
               subject.should be_instance_of MassiveRecord::ORM::Persistence::Operations::Suppress
             end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
massive_record-0.2.2.rc1 spec/orm/persistence/operations_spec.rb