Sha256: c544ef0eced7c6c08fb0447102e7a948c17dc6a21d16a31fc0a7a804ab29b952

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"

module RockConfig
  describe Manager do
    let(:configuration) { Configuration.new }

    it "returns config if found" do
      result = mock("Config")
      result.should_receive(:send).with("development") { "yay" }

      scanner = mock("Scanner")
      scanner.should_receive(:new) .with(configuration) { scanner }
      scanner.should_receive(:find).with("sample")      { result }

      manager         = Manager.new(configuration, scanner)
      manager_result  = manager.fetch "sample", "development"

      manager_result.should eq("yay")
    end

    it "raises error if the config doesnt have the environment"  do
      result = mock("Config")
      result.should_receive(:send).with("development") { nil }

      scanner = mock("Scanner")
      scanner.should_receive(:new) .with(configuration) { scanner }
      scanner.should_receive(:find).with("sample")      { result }

      manager = Manager.new(configuration, scanner)
      expect do
        manager_result  = manager.fetch "sample", "development"
      end.to raise_error(EnvironmentNotFoundError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rock_config-0.0.3 spec/manager_spec.rb
rock_config-0.0.2 spec/manager_spec.rb