Sha256: 8cae7c6a69c6a854d5a43d856abe30ac10c104f19cc8ae5ac8d3a6f9bd3565a0

Contents?: true

Size: 1.55 KB

Versions: 43

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Trackman::Assets::Components::Diffable do
  class TestDiff
    extend Trackman::Assets::Components::Diffable
  end
 
  it "specify the html to update and the image to delete" do    
    expected = { 
      :create => [], 
      :update => [Asset.create(:path => 'spec/test_data/sample.html')], 
      :delete => [ Asset.create(:path => 'spec/test_data/test1.jpeg')]
    }
    
    remote = [
      RemoteAsset.new(:path => 'spec/test_data/sample.html', :file_hash => 'abcd123'), 
      RemoteAsset.new(:path => 'spec/test_data/test1.jpeg', :file_hash => '12345')
    ]
    
    local = [Asset.create(:path => 'spec/test_data/sample.html')]

    actual = TestDiff.diff local, remote
    
    actual.should eq(expected)
  end

  it "returns the file to create if it is missing remotely" do
    expected = { 
      :create => [Asset.create(:path => 'spec/test_data/test1.jpeg')], 
      :update => [], 
      :delete => []
    }

    html_asset = Asset.create(:path => 'spec/test_data/sample.html')
    remote = [html_asset]
    local = [html_asset, Asset.create(:path => 'spec/test_data/test1.jpeg')]

    actual = TestDiff.diff local, remote

    actual.should eq(expected)
  end

  it "can not mark html remotes as deleted" do
    expected = { 
      :create => [], 
      :update => [], 
      :delete => []
    }

    asset1 = RemoteAsset.create(:path => 'spec/test_data/sample.html')
    asset2 = RemoteAsset.create(:path => 'spec/test_data/external_paths/1.html')

    actual = TestDiff.diff([], [asset1, asset2])

    actual.should eq(expected)
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
trackman-0.4.2 spec/diffable_spec.rb
trackman-0.4.1 spec/diffable_spec.rb
trackman-0.4.0 spec/diffable_spec.rb
trackman-0.3.5 spec/diffable_spec.rb
trackman-0.3.4 spec/diffable_spec.rb
trackman-0.3.2 spec/diffable_spec.rb
trackman-0.3.1 spec/diffable_spec.rb
trackman-0.3.0 spec/diffable_spec.rb
trackman-0.2.90 spec/diffable_spec.rb
trackman-0.2.89 spec/diffable_spec.rb
trackman-0.2.88 spec/diffable_spec.rb
trackman-0.2.87 spec/diffable_spec.rb
trackman-0.2.86 spec/diffable_spec.rb
trackman-0.2.85 spec/diffable_spec.rb
trackman-0.2.84 spec/diffable_spec.rb
trackman-0.2.83 spec/diffable_spec.rb
trackman-0.2.82 spec/diffable_spec.rb
trackman-0.2.81 spec/diffable_spec.rb
trackman-0.2.80 spec/diffable_spec.rb
trackman-0.2.65 spec/diffable_spec.rb