Sha256: 0bf6554a8057889545d24d4b2f015223718136f52c5b53203ab66289232f2c68

Contents?: true

Size: 1.96 KB

Versions: 11

Compression:

Stored size: 1.96 KB

Contents

require_relative '../spec_helper'

describe Cranium::DataImporter do

  before do
    connection = double
    allow(Cranium::Database).to receive(:connection).and_return connection
    allow(connection).to receive(:transaction).and_yield
  end

  let(:importer) { Cranium::DataImporter.new }
  let(:definition) { Cranium::DSL::ImportDefinition.new "definition_name" }

  describe "#import" do

    context "when called with both merge and delete_insert fields set" do
      it "should raise an exception" do
        definition.delete_insert_on :some_field
        definition.merge_on :another_field

        expect { importer.import(definition) }.to raise_error StandardError, "Import should not combine merge_on, delete_insert_on and truncate_insert settings"
      end
    end

    context "when called with both merge and truncate_insert fields set" do
      it "should raise an exception" do
        definition.truncate_insert true
        definition.merge_on :another_field

        expect { importer.import(definition) }.to raise_error StandardError, "Import should not combine merge_on, delete_insert_on and truncate_insert settings"
      end
    end

    context "when called with both delete_insert and truncate_insert fields set" do
      it "should raise an exception" do
        definition.delete_insert_on :some_field
        definition.truncate_insert true

        expect { importer.import(definition) }.to raise_error StandardError, "Import should not combine merge_on, delete_insert_on and truncate_insert settings"
      end
    end

    context "when called with both merge, delete_insert and truncate_insert fields set" do
      it "should raise an exception" do
        definition.delete_insert_on :some_field
        definition.merge_on :another_field
        definition.truncate_insert true

        expect { importer.import(definition) }.to raise_error StandardError, "Import should not combine merge_on, delete_insert_on and truncate_insert settings"
      end
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cranium-0.7 spec/cranium/data_importer_spec.rb
cranium-0.6.1 spec/cranium/data_importer_spec.rb
cranium-0.5 spec/cranium/data_importer_spec.rb
cranium-0.4.3 spec/cranium/data_importer_spec.rb
cranium-0.4.2 spec/cranium/data_importer_spec.rb
cranium-0.4.1 spec/cranium/data_importer_spec.rb
cranium-0.4 spec/cranium/data_importer_spec.rb
cranium-0.3.1 spec/cranium/data_importer_spec.rb
cranium-0.3.0 spec/cranium/data_importer_spec.rb
cranium-0.2.1 spec/cranium/data_importer_spec.rb
cranium-0.2.0 spec/cranium/data_importer_spec.rb