Sha256: 204eec2888cf91516f9b4cd1c5b7ee322c4895bd7a5562b4fdb3e9026111a019

Contents?: true

Size: 1023 Bytes

Versions: 5

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"
require "roadie/rspec"

describe TestProvider do
  subject(:provider) { TestProvider.new }

  it_behaves_like "roadie asset provider", valid_name: "existing.css", invalid_name: "invalid.css" do
    subject { TestProvider.new "existing.css" => "" }
  end

  it "finds styles from a predefined hash" do
    provider = TestProvider.new({
      "foo.css" => "a { color: red; }",
      "bar.css" => "body { color: green; }"
    })
    expect(provider.find_stylesheet("foo.css").to_s).not_to include("body")
    expect(provider.find_stylesheet("bar.css").to_s).to include("body")
    expect(provider.find_stylesheet("baz.css")).to be_nil
  end

  it "can have a default for missing entries" do
    provider = TestProvider.new({
      "foo.css" => "a { color: red; }",
      :default => "body { color: green; }"
    })
    expect(provider.find_stylesheet("foo.css").to_s).not_to include("body")
    expect(provider.find_stylesheet("bar.css").to_s).to include("body")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roadie-5.2.1 spec/lib/roadie/test_provider_spec.rb
roadie-5.2.0 spec/lib/roadie/test_provider_spec.rb
roadie-5.1.0 spec/lib/roadie/test_provider_spec.rb
roadie-5.0.1 spec/lib/roadie/test_provider_spec.rb
roadie-5.0.0 spec/lib/roadie/test_provider_spec.rb