Sha256: dd0e3707ff9e87f07387058de1027c8fe290a071ee1b835ad0e5122cb7ef33b5

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

require "hanami/view"
require "hanami/view/context"
require "hanami/extensions/view/context"

RSpec.describe(Hanami::View::Context) do
  subject(:context) { described_class.new(**args) }
  let(:args) { {} }

  describe "#assets" do
    context "assets given" do
      let(:args) { {assets: assets} }
      let(:assets) { double(:assets) }

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

    context "no assets given" do
      it "raises a Hanami::ComponentLoadError" do
        expect { context.assets }.to raise_error Hanami::ComponentLoadError
      end
    end
  end

  describe "#request" do
    context "request given" do
      let(:args) { {request: request} }
      let(:request) { double(:request) }

      it "returns the request" do
        expect(context.request).to be request
      end
    end

    context "no request given" do
      it "raises a Hanami::ComponentLoadError" do
        expect { context.request }.to raise_error Hanami::ComponentLoadError
      end
    end
  end

  describe "#routes" do
    context "routes given" do
      let(:args) { {routes: routes} }
      let(:routes) { double(:routes) }

      it "returns the routes" do
        expect(context.routes).to be routes
      end
    end

    context "no routes given" do
      it "raises a Hanami::ComponentLoadError" do
        expect { context.routes }.to raise_error Hanami::ComponentLoadError
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.2.0 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.2.0.rc1 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.2.0.beta2 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.2.0.beta1 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.rc3 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.rc2 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.rc1 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.beta2.1 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.beta2 spec/unit/hanami/extensions/view/context_spec.rb
hanami-2.1.0.beta1 spec/unit/hanami/extensions/view/context_spec.rb