Sha256: 7200e69265a59fb54a591f734da1abf88989690e79eeff2c3b96bf0b6e27c87f

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "hanami"

RSpec.describe "App view / Context / Settings", :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 "#settings" do
    it "is the app settings by default" do
      expect(context.settings).to be TestApp::App.settings
    end

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

      let(:settings) { double(:settings) }

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

      context "rebuilt context" do
        subject(:new_context) { context.with }

        it "retains the injected settings" do
          expect(new_context.settings).to be settings
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.0.0.beta1.1 spec/new_integration/view/context/settings_spec.rb
hanami-2.0.0.beta1 spec/new_integration/view/context/settings_spec.rb