Sha256: b6ebd94ee1d529d5dd50c90c86caf9eec799bfc4f315facd3c862fc0afd488da

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

describe Convoy::Setup::Configuration::Reader do
    include FakeFS::SpecHelpers

    let(:reader) { Convoy::Setup::Configuration::Reader.new(path) }
    let(:path) { '/usr/alan/blah.json' }
    let(:data) { { :hello => :world } }

    describe "#read" do
        subject { reader.read }

        context "when path not given" do
            let(:path) { nil }
            it { subject.should be_empty }
        end

        context "when configuration file not present" do
            before do
                FileUtils.mkdir_p(File.dirname path)
            end
            it { subject.should be_empty }
        end

        context "when configuration file not JSON" do
            before do
                FileUtils.mkdir_p(File.dirname path)
                File.open(path, 'w') { |f| f.write("hello") }
            end
            it { subject.should be_empty }
        end

        context "when configuration file present" do
            let(:config_data) { { :hello => :blah } }

            before do
                FileUtils.mkdir_p(File.dirname path)
                File.open(path, 'w') { |f| f.write(JSON.pretty_generate(config_data)) }
            end
            it { subject.data.should == { :hello => "blah" } }
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
convoy-1.3.2 spec/lib/convoy/setup/configuration/reader_spec.rb
convoy-1.2.0 spec/lib/convoy/setup/configuration/reader_spec.rb