Sha256: 9915b7942f9b21c2349f6b780613c2dbadc7e758ab1855de66347220393c9dca

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "hanami/config"

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

  describe "environment-specific config" do
    before do
      config.logger.level = :debug__set_without_env
    end

    before do
      config.environment :production do |c|
        c.logger.level = :info__set_for_production_env
      end
    end

    context "settings configured for current env" do
      let(:env) { :production }

      it "applies the settings" do
        expect(config.logger.level).to eq :info__set_for_production_env
      end

      it "leaves the settings in place when finalizing" do
        expect { config.finalize! }.not_to(change { config.logger.level })
      end
    end

    context "settings configured for a different env" do
      let(:env) { :development }

      it "does not apply the settings" do
        expect(config.logger.level).to eq :debug__set_without_env
      end

      it "does not apply the settings when finalizing" do
        expect { config.finalize! }.not_to(change { config.logger.level })
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.0.0.beta4 spec/unit/hanami/config_spec.rb