Sha256: be5a61900e46f96902bad88ff82e1928314d81506f76956c02383ffd8772c61e

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper')

describe Rack::Bundle::FileSystemStore do  
  it "stores bundles in a location specified on the argument when instancing" do
    Rack::Bundle::FileSystemStore.new(FIXTURES_PATH).dir.should == FIXTURES_PATH
  end
  
  it "keeps a collection of bundles in #bundles" do
    subject.bundles.should be_an Array
  end
  
  it "defaults to the system's temporary dir" do
    subject.dir.should == Dir.tmpdir
  end
  
  context 'storing bundles in the file system' do
    before do
      @store = Rack::Bundle::FileSystemStore.new FIXTURES_PATH
      @jsbundle   = mock Rack::Bundle::JSBundle, 
        :contents   => 'All we are saaaaaayin...', 
        :hash       => MD5.new($jquery),
        :extension  => 'js'
      @cssbundle  = mock Rack::Bundle::CSSBundle, 
        :contents   => '... is give peace a chaaaaance', 
        :hash       => MD5.new($screen),
        :extension  => 'css'
      @store.bundles.concat [@jsbundle, @cssbundle]
      @store.save!
    end
    
    it "checks if a bundle exists with #has_bundle?" do
      @store.has_bundle?(@jsbundle).should be_true
    end

    it 'skips saving a bundle if one with a matching hash already exists' do
      File.should_not_receive(:open)
      @store.save!
    end
    
    it 'stores Javascripts in a single Javascript file' do
      File.size(File.join(@store.dir, "rack-bundle-#{@jsbundle.hash}.js")).should > 0
    end
    
    it 'stores stylesheets in a single CSS file' do
      File.size(File.join(@store.dir, "rack-bundle-#{@cssbundle.hash}.css")).should > 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-bundle-0.1.0 spec/store/file_system_store_spec.rb