Sha256: ed38bd1fce6eccc0c8fc5fdf3b20d2db2691fcb474c22102f8b75eb9c2c5e0a9

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8
RSpec.describe Middleman::Sprockets::ImportedAsset do

  describe "#initialize" do
    it "sets #logical_path to a pathname based on given path" do
      subject = described_class.new "logical"
      expect( subject.logical_path ).to eq Pathname.new("logical")
    end

    it "sets #output_path to nil if no block given" do
      subject = described_class.new "logical"
      expect( subject.output_path ).to be_nil
    end

    it "sets #output_path based on return of passed block" do
      subject = described_class.new "logical", -> { "hello" }
      expect( subject.output_path ).to eq Pathname.new("hello")
    end

    it "passes #logical_path to the output_path block if it accepts an argument" do
      output_double = proc { |arg| "hello" }
      expect( output_double ).to receive(:call).with(Pathname.new("logical"))

      described_class.new "logical", output_double
    end

    it "passes #logical_path to the output_path block if it accepts an argument and has a default", skip: '1.9' do
      output_double = lambda { |arg=3| "hello" }
      expect( output_double ).to receive(:call).with(Pathname.new("logical"))

      described_class.new "logical", output_double
    end

    it "calls output_path block with no args it it accepts none" do
      output_double = -> { "hello" }
      expect( output_double ).to receive(:call).with no_args()

      described_class.new "logical", output_double
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
middleman-sprockets-3.5.0 spec/imported_asset_spec.rb
middleman-sprockets-4.0.0.beta.1 spec/imported_asset_spec.rb
middleman-sprockets-3.4.2 spec/imported_asset_spec.rb
middleman-sprockets-3.4.1 spec/imported_asset_spec.rb