Sha256: 7edd1c81c9e5ca949caa52e32c591e93aa47a1051f7380b4f6b2f737a2004fa9

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'


module Jekyll::AssetsPlugin
  describe SitePatch do
    let(:site) do
      Class.new(Jekyll::Site) do
        include SitePatch

        def initialize
          self.reset
        end

        def config
          @config ||= {
            'dirname' => 'foobar',
            'assets'  => {
              'sources' => [ 'foobar', '_assets' ]
            }
          }
        end

        def source
          @source ||= RSpecHelpers.fixtures_path.to_s
        end
      end.new
    end

    context '#assets' do
      subject { site.assets }
      it { should be_an_instance_of Sprockets::Environment }

      context 'calling #asset_path within assets' do
        context 'when requested file not found' do
          it 'should raise a NotFound error' do
            Proc.new do
              site.assets["should_fail.css"]
            end.should raise_error(AssetFile::NotFound)
          end
        end

        context 'when requested file found' do
          it 'should have proper asset path' do
            noise_img_re = %r{url\(/assets/noise-[a-f0-9]{32}\.png\)}
            site.assets["app.css"].to_s.should match(noise_img_re)
          end

          it 'should be appended to the static files list' do
            asset = site.assets["app.css"] # make sure main asset was compiled
            asset = site.assets["noise.png"]

            site.static_files.include?(asset).should be_true
          end
        end
      end
    end

    context '#assets_config' do
      subject { site.assets_config }
      it { should be_an_instance_of Configuration }

      it 'should been populated with `assets` section of config' do
        site.assets_config.dirname.should_not == 'foobar'
        site.assets_config.sources.should include 'foobar'
      end
    end

    it 'should be included into Jekyll::Site' do
      Jekyll::Site.included_modules.should include SitePatch
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-assets-0.3.0 spec/lib/jekyll/assets_plugin/site_patch_spec.rb
jekyll-assets-0.2.3 spec/lib/jekyll/assets_plugin/site_patch_spec.rb
jekyll-assets-0.2.2 spec/lib/jekyll/assets_plugin/site_patch_spec.rb
jekyll-assets-0.2.1 spec/lib/jekyll/assets_plugin/site_patch_spec.rb
jekyll-assets-0.2.0 spec/lib/jekyll/assets_plugin/site_patch_spec.rb