Sha256: 0f303e6d0cc8f1267f76fcff06a0b5e16298072c3650812a24f9ed1ed29ad423

Contents?: true

Size: 1.48 KB

Versions: 16

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require "hanami/config"
require "hanami/action"

RSpec.describe Hanami::Config, "#actions" do
  let(:config) { described_class.new(app_name: app_name, env: :development) }
  let(:app_name) { "MyApp::app" }

  subject(:actions) { config.actions }

  context "hanami-controller is bundled" do
    it "is a full actions config" do
      is_expected.to be_an_instance_of(Hanami::Config::Actions)

      is_expected.to respond_to(:format)
    end

    it "configures base action settings" do
      expect { actions.public_directory = "pub" }
        .to change { actions.public_directory }
        .to end_with("pub")
    end

    it "configures base actions settings using custom methods" do
      expect { actions.formats.add(:json, "app/json") }
        .to change { actions.formats.mapping }
        .to include("app/json" => :json)
    end

    it "can be finalized" do
      is_expected.to respond_to(:finalize!)
    end
  end

  context "hanami-controller is not bundled" do
    before do
      allow(Hanami).to receive(:bundled?).and_call_original
      expect(Hanami).to receive(:bundled?).with("hanami-controller").and_return(false)
    end

    it "does not expose any settings" do
      is_expected.to be_an_instance_of(Hanami::Config::NullConfig)
      is_expected.not_to respond_to(:default_response_format)
      is_expected.not_to respond_to(:default_response_format=)
    end

    it "can be finalized" do
      is_expected.to respond_to(:finalize!)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/unit/hanami/config/actions_spec.rb
hanami-2.2.0 spec/unit/hanami/config/actions_spec.rb
hanami-2.2.0.rc1 spec/unit/hanami/config/actions_spec.rb
hanami-2.2.0.beta2 spec/unit/hanami/config/actions_spec.rb
hanami-2.2.0.beta1 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.rc3 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.rc2 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.rc1 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.beta2.1 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.beta2 spec/unit/hanami/config/actions_spec.rb
hanami-2.1.0.beta1 spec/unit/hanami/config/actions_spec.rb
hanami-2.0.3 spec/unit/hanami/config/actions_spec.rb
hanami-2.0.2 spec/unit/hanami/config/actions_spec.rb
hanami-2.0.1 spec/unit/hanami/config/actions_spec.rb
hanami-2.0.0 spec/unit/hanami/config/actions_spec.rb