Sha256: 37be3d2847a35920c20254a0626ed8ed738c6af86d54b6b832e9cf984aeb3f9c

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require "hanami"

RSpec.describe "App view / Context / Assets", :app_integration do
  before do
    module TestApp
      class App < Hanami::App
      end
    end

    Hanami.prepare

    module TestApp
      module Views
        class Context < Hanami::View::Context
        end
      end
    end
  end

  let(:context_class) { TestApp::Views::Context }
  subject(:context) { context_class.new }

  describe "#assets" do
    context "without assets provider" do
      xit "raises error" do
        allow(Hanami).to receive(:bundled?).with("hanami-assets").and_return(false)

        expect { context.assets }
          .to raise_error(Hanami::ComponentLoadError, /hanami-assets/)
      end
    end

    context "with assets provider" do
      it "is the app assets by default" do
        expect(context.assets).to be TestApp::App[:assets]
      end

      context "injected assets" do
        subject(:context) {
          context_class.new(assets: assets)
        }

        let(:assets) { double(:assets) }

        it "is the injected assets" do
          expect(context.assets).to be assets
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.1.0.rc2 spec/integration/view/context/assets_spec.rb
hanami-2.1.0.rc1 spec/integration/view/context/assets_spec.rb