Sha256: 7f67a14b9a445725f9e942fdc6dafbfb1f1a0fbbd2197552a1d17ff4475413e8

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

require 'spec/spec_helper'

describe Upstart::Exporter::Options::Global do
  let(:defaults){ Upstart::Exporter::Options::Global::DEFAULTS }
  let(:conf){ Upstart::Exporter::Options::Global::CONF }
  

  it "should give access to options like a hash" do
    capture(:stderr) do
      described_class.new.should respond_to('[]')
    end
  end

  context "when no config present" do

    it "should provide default options" do
      capture(:stderr) do
        options = described_class.new
        defaults.each do |option, default_value|
          options[option.to_sym].should == default_value
        end
      end
    end

  end

  context "when invalid config is given" do
    it "should raise exception" do
      make_global_config('zxc')
      lambda{described_class.new}.should raise_exception
      make_global_config([123].to_yaml)
      lambda{described_class.new}.should raise_exception
    end
  end

  context "when a valid config is given" do
    it "should override default values" do
      capture(:stderr) do
        make_global_config({'run_user' => 'wwwww'}.to_yaml)
        described_class.new[:run_user].should == 'wwwww'
      end
    end
    
    it "should preserve default values for options not specified in the config" do
      capture(:stderr) do
        make_global_config({'run_user' => 'wwwww'}.to_yaml)
        described_class.new[:prefix] == defaults['prefix']
      end
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
upstart-exporter-1.0.1 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-1.0.0 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-0.1.4 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-0.1.3 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-0.1.2 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-0.1.1 spec/lib/upstart-exporter/options/global_spec.rb
upstart-exporter-0.1.0 spec/lib/upstart-exporter/options/global_spec.rb