Sha256: ebbe1eeafea8c7aeba0370d4c7334931884af116dca7c4029e3f0cf213c9105a

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Assetify do
  include Assetify

  def mock_jsfile(d = 'js "cool", "http://cool.js/down"')
    File.should_receive(:open).once.with("Jsfile").and_return(d)
  end

  it "shoud read_jsfile" do
    mock_jsfile
    Assetify.read_jsfile.should have(1).asset
  end

  it "should skip comments" do
    mock_jsfile("#\n# Oi\n#\n")
    Assetify.read_jsfile.should be_empty
  end

  it "should work with versions url" do
    mock_jsfile("#\n# Oi\n#\njs 'down', 'http://js.com/down-{VERSION}.js', '1.6'")
    Assetify.read_jsfile.first.url.should eql("http://js.com/down-1.6.js")
  end

  describe "read css" do
    before do
      mock_jsfile("#\n# CSS\n#\ncss 'grid', 'http://grid.com/down'")
    end
    let(:asset) { Assetify.read_jsfile[0] }

    it "should read css" do
      Assetify.read_jsfile.should have(1).asset
    end

    it "should read css" do
      Assetify.read_jsfile.first.type.should eql(:css)
    end

    it "should have fullpath" do
      asset.fullpath.should eql("public/stylesheets/grid.css")
    end

  end

  describe "readjs" do

    let(:asset) { mock_jsfile; Assetify.read_jsfile[0] }

    it "should be an asset" do
      asset.should be_an Assetify::Asset
    end

    it "should be a js file" do
      asset.type.should eql(:js)
    end

    it "should have an url" do
      asset.url.should eql("http://cool.js/down")
    end

    it "should have a name" do
      asset.name.should eql("cool")
    end

    it "should have fullpath" do
      asset.fullpath.should eql("public/javascripts/cool.js")
    end


  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assetify-0.0.2 spec/assetify_spec.rb
assetify-0.0.1 spec/assetify_spec.rb