Sha256: f5db7344e6e95804b13182fec43992f8690515c863767eef59fe7e4ded31f979

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

class ClientDouble
  def entries
    []
  end
end

describe ContentfulMiddleman::ImportTask do
  let(:path) { File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'space_hash_fixtures')) }
  subject { described_class.new 'foobar', {}, {}, ClientDouble.new }

  describe 'instance methods' do
    before do
        ContentfulMiddleman::VersionHash.source_root = path
    end

    describe '#run' do
      it 'doesnt change when data did not change' do
        expect_any_instance_of(ContentfulMiddleman::LocalData::Store).to receive(:write)

        subject.run
        expect(subject.changed_local_data?).to eq(false)
      end

      it 'changes when data is new' do
        subject = described_class.new 'blah', {}, {}, ClientDouble.new

        if ::File.exist?(::File.join(path, '.blah-space-hash'))
          ::File.delete(::File.join(path, '.blah-space-hash'))
        end

        expect_any_instance_of(ContentfulMiddleman::LocalData::Store).to receive(:write)

        subject.run

        expect(subject.changed_local_data?).to eq(true)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contentful_middleman-1.3.1 spec/contentful_middleman/import_task_spec.rb
contentful_middleman-1.2.0 spec/contentful_middleman/import_task_spec.rb