Sha256: a77ed2323d1d62744638295a6b36274e2a31c6fada975df7bac59bd0e4d78aa8

Contents?: true

Size: 1.6 KB

Versions: 38

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

describe Trackman::Assets::HtmlAsset do  
  it "should contains every image within the html as assets" do
    asset = Asset.create(:path => 'spec/test_data/sample.html')

    expected = [
      'spec/test_data/test1.jpeg', 
      'spec/test_data/test2.png', 
      'spec/test_data/test3.gif'
    ].map{|x| Asset.create(:path => x) } 
    
    actual = asset.assets.select{|a| !(['.css', '.js'].include?(a.path.extname)) }

    actual.should eq(expected)
  end  

   
  it "should contains every js within the html as assets" do
    asset = Asset.create(:path => 'spec/test_data/sample.html')

    expected = ['a', 'b', 'c'].map{|x| Asset.create(:path =>"spec/test_data/#{x}.js") } 
    
    actual = asset.assets.select{|a| a.path.extname == '.js'}

    actual.should eq(expected)
  end
  
  it "should contains every css within the html as assets" do
    asset = Asset.create(:path => 'spec/test_data/sample.html')

    expected = ['y', 'z'].map{|x| Asset.create(:path => "spec/test_data/#{x}.css") } 
    
    actual = asset.assets.select{|a| a.path.extname == '.css'}

    actual.should eq(expected)
  end

  it "returns all recursive css imports and images under the html file that contains css" do
    expected = [
        CssAsset.new(:path => 'spec/test_data/css/recursive/imported-lvl2.css'),
        CssAsset.new(:path => 'spec/test_data/css/recursive/imported-lvl3.css'),
        Asset.new(:path => 'spec/test_data/css/recursive/riding-you.jpg')
      ]
    asset = Asset.create(:path => 'spec/test_data/css/recursive/html-with-css.html')

    actual = asset.assets

    actual.should == expected
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
trackman-0.3.2 spec/html_asset_spec.rb
trackman-0.3.1 spec/html_asset_spec.rb
trackman-0.3.0 spec/html_asset_spec.rb
trackman-0.2.90 spec/html_asset_spec.rb
trackman-0.2.89 spec/html_asset_spec.rb
trackman-0.2.88 spec/html_asset_spec.rb
trackman-0.2.87 spec/html_asset_spec.rb
trackman-0.2.86 spec/html_asset_spec.rb
trackman-0.2.85 spec/html_asset_spec.rb
trackman-0.2.84 spec/html_asset_spec.rb
trackman-0.2.83 spec/html_asset_spec.rb
trackman-0.2.82 spec/html_asset_spec.rb
trackman-0.2.81 spec/html_asset_spec.rb
trackman-0.2.80 spec/html_asset_spec.rb
trackman-0.2.65 spec/html_asset_spec.rb
trackman-0.2.64 spec/html_asset_spec.rb
trackman-0.2.63 spec/html_asset_spec.rb
trackman-0.2.62 spec/html_asset_spec.rb
trackman-0.2.61 spec/html_asset_spec.rb
trackman-0.2.5 spec/html_asset_spec.rb