Sha256: 274cc914820e2e6464d15ae6a43f89fdbcd3d94a878d6024db0240efb2269fc7

Contents?: true

Size: 1.54 KB

Versions: 13

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Trackman::Components::Diffable do
  class TestDiff
    extend Trackman::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.create(:path => 'spec/test_data/sample.html', :file_hash => 'abcd123'), 
      RemoteAsset.create(: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

13 entries across 13 versions & 1 rubygems

Version Path
trackman-0.6.8 spec/diffable_spec.rb
trackman-0.6.7 spec/diffable_spec.rb
trackman-0.6.6 spec/diffable_spec.rb
trackman-0.6.5 spec/diffable_spec.rb
trackman-0.6.4 spec/diffable_spec.rb
trackman-0.6.3 spec/diffable_spec.rb
trackman-0.6.2 spec/diffable_spec.rb
trackman-0.6.1 spec/diffable_spec.rb
trackman-0.6.0 spec/diffable_spec.rb
trackman-0.5.8 spec/diffable_spec.rb
trackman-0.5.7 spec/diffable_spec.rb
trackman-0.5.6 spec/diffable_spec.rb
trackman-0.5.5 spec/diffable_spec.rb