Sha256: e7d900360688d8d934e6dc969a054b73ccab8ea9afba6d279c180f9a1e5eb07a

Contents?: true

Size: 1.84 KB

Versions: 22

Compression:

Stored size: 1.84 KB

Contents

# coding: utf-8
# frozen_string_literal: true

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Stealth::Configuration" do

  describe "accessing via method calling" do
    let(:services_yml) { File.read(File.join(File.dirname(__FILE__), 'support', 'services.yml')) }
    let(:parsed_config) { YAML.load(ERB.new(services_yml).result)[Stealth.env] }
    let(:config) { Stealth.load_services_config!(services_yml) }

    it "should return the root node" do
      expect(config.facebook).to eq parsed_config['facebook']
    end

    it "should access deeply nested nodes" do
      expect(config.facebook.setup.greeting).to eq parsed_config['facebook']['setup']['greeting']
    end

    it "should handle values that are arrays correctly" do
      expect(config.facebook.setup.persistent_menu).to be_a(Array)
    end

    it "should retain the configuration at the class level" do
      expect(Stealth.config.facebook.setup.greeting).to eq parsed_config['facebook']['setup']['greeting']
    end

    it "should handle multiple keys at the root level" do
      expect(config.twilio_sms.account_sid).to eq parsed_config['twilio_sms']['account_sid']
    end
  end

  describe "config files with ERB" do
    let(:services_yml) { File.read(File.join(File.dirname(__FILE__), 'support', 'services_with_erb.yml')) }
    let(:config) { Stealth.load_services_config!(services_yml) }

    it "should replace available embedded env vars" do
      ENV['FACEBOOK_VERIFY_TOKEN'] = 'it works'
      expect(config.facebook.verify_token).to eq 'it works'
    end

    it "should replace unavailable embedded env vars with nil" do
      expect(config.facebook.challenge).to be_nil
    end

    it "should not reload the configuration file if one already exists" do
      Stealth.load_services_config(services_yml)
      expect(config.facebook.challenge).to be_nil
    end
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
stealth-1.1.6 spec/configuration_spec.rb
stealth-1.1.5 spec/configuration_spec.rb
stealth-1.1.4 spec/configuration_spec.rb
stealth-1.1.3 spec/configuration_spec.rb
stealth-1.1.2 spec/configuration_spec.rb
stealth-1.1.1 spec/configuration_spec.rb
stealth-1.1.0 spec/configuration_spec.rb
stealth-1.1.0.rc3 spec/configuration_spec.rb
stealth-1.1.0.rc2 spec/configuration_spec.rb
stealth-1.1.0.rc1 spec/configuration_spec.rb
stealth-1.0.4 spec/configuration_spec.rb
stealth-1.0.3 spec/configuration_spec.rb
stealth-1.0.2 spec/configuration_spec.rb
stealth-1.0.1 spec/configuration_spec.rb
stealth-1.0.0 spec/configuration_spec.rb
stealth-1.0.0.rc1 spec/configuration_spec.rb
stealth-1.0.0.pre2 spec/configuration_spec.rb
stealth-1.0.0.pre1 spec/configuration_spec.rb
stealth-0.10.6 spec/configuration_spec.rb
stealth-0.10.5 spec/configuration_spec.rb