Sha256: c4d8aad74d5e0bfd445fa071695e41165dd0e001e4cb26652cd038337300061d

Contents?: true

Size: 1008 Bytes

Versions: 5

Compression:

Stored size: 1008 Bytes

Contents

require_relative "spec_helper_initializer"

describe "DigestStrategy" do
  def remove_compilation_digest_path
    @digest_strategy.send(:compilation_digest_path).tap do |path|
      path.delete if path.exist?
    end
  end

  before :all do
    @digest_strategy = Webpacker::DigestStrategy.new
    ENV["SHAKAPACKER_ASSET_HOST"] = nil
    remove_compilation_digest_path
  end

  after :all do
    remove_compilation_digest_path
  end

  it "is not fresh before compilation" do
    expect(@digest_strategy.stale?).to be true
    expect(@digest_strategy.fresh?).to be_falsy
  end

  it "is fresh after compilation" do
    @digest_strategy.after_compile_hook

    expect(@digest_strategy.stale?).to be false
    expect(@digest_strategy.fresh?).to be true
  end

  it "generates correct compilation_digest_path" do
    actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
    expected_path = "last-compilation-digest-#{Webpacker.env}"

    expect(actual_path).to eq expected_path
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shakapacker-7.2.3 spec/backward_compatibility_specs/digest_strategy_spec.rb
shakapacker-7.3.0.beta.1 spec/backward_compatibility_specs/digest_strategy_spec.rb
shakapacker-7.2.2 spec/backward_compatibility_specs/digest_strategy_spec.rb
shakapacker-7.2.1 spec/backward_compatibility_specs/digest_strategy_spec.rb
shakapacker-7.2.0 spec/backward_compatibility_specs/digest_strategy_spec.rb