Sha256: 5ac74e5e0627d0c630744cfd6cbb805090aa555395ef1cd221c4071aee9e70f0

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Topographer::Importer::Strategy::Base do
  let(:mapper) do
    double('Mapper')
  end
  let(:strategy) { Topographer::Importer::Strategy::Base.new(mapper) }
  let(:status) do
    double 'Status',
           errors?: false
  end
  let(:bad_status) do
    double 'Status',
           errors?: true
  end
  describe '#initialize' do
    it 'creates a new Strategy instance with the given mapper' do
      strategy = Topographer::Importer::Strategy::Base.new(mapper)
      strategy.instance_variable_get(:@mapper).should be(mapper)
    end
  end
  describe '#import_record' do
    it 'should raise NotImplementedError' do
      expect { strategy.import_record(nil) }.to raise_error(NotImplementedError)
    end
  end

  describe '#should_persist_import?' do
    it 'returns true if the status has no errors and the import is not a dry run' do
      expect(strategy.should_persist_import?(status)).to be_true
    end
    it 'returns false if the status has errors regardless of whether the import is a dry run or not' do
      expect(strategy.should_persist_import?(bad_status)).to be_false
      strategy.dry_run = true
      expect(strategy.should_persist_import?(bad_status)).to be_false
    end
    it 'returns false if the status has no errors and the import is a dry run' do
      strategy.dry_run = true
      expect(strategy.should_persist_import?(status)).to be_false
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
topographer-0.0.7 spec/topographer/importer/strategy/base_spec.rb
topographer-0.0.6 spec/topographer/importer/strategy/base_spec.rb
topographer-0.0.5 spec/topographer/importer/strategy/base_spec.rb
topographer-0.0.4 spec/topographer/importer/strategy/base_spec.rb
topographer-0.0.3 spec/Topographer/importer/strategy/base_spec.rb
topographer-0.0.2 spec/Cartographer/importer/strategy/base_spec.rb