Sha256: ba1f871a2d3a1e46fc53d98dcb4ee023bdef55b86728e2b908d800f0f6d71d40

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

RSpec.describe Rails::Service::Manifest do
  let(:path) { 'app-manifest.yaml' }
  let(:logger) { double(:logger) }
  let(:manifest) { described_class.new(path: path, logger: logger) }

  before do
    @root_old = Rails.root
    Rails.application.config.root = File.expand_path('spec/fixtures')
  end

  after do
    Rails.application.config.root = @root_old
  end

  describe 'chain method access to properties' do
    before do
      allow(logger).to receive(:info)
    end

    it 'should work with nested properties' do
      expect(manifest.setup.nodes).to be_kind_of(Array)
    end

    it 'should evaluate erb' do
      expect(manifest.magic).to eq 4
    end

    it 'should convert to hash' do
      expect(manifest.to_h).to eq(
        'app' => 'fooxample',
        'setup' => {
          'nodes' => [
            'abc123.nyc.acme',
            'abc456.nyc.acme',
            'abc789.nyc.acme',
          ],
        },
        'magic' => 4,
      )
    end
  end

  describe 'loading file' do
    context 'file not exists' do
      let(:path) { 'dobrypies.yaml' }

      it 'log that file was not' do
        expect(logger).to receive(:warn)
        manifest
      end
    end

    context 'file exists' do
      it 'log that file was loaded' do
        expect(logger).to receive(:info)
        manifest
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-service-0.1.0 spec/lib/manifest_spec.rb