Sha256: 7520e95f2d270804b8d586957f011651d6dccca2d8e66f87452a17776e23d7dd

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
require 'jira_report/config_loader'

module JiraReport
  describe ConfigLoader do
    it 'raises error if wrong path to configuration file' do
      expect{ ConfigLoader.load_config('wrong/path') }.to raise_error RuntimeError
    end

    context 'when file exists' do
      let(:filename){ 'test.conf' }
      let(:option){ 'username' }
      let(:value){ 'JohnDoe' }

      before do
        FileUtils.touch(filename)
      end

      def add_content(filename, content)
        f = File.new(filename, 'a+')
        f.write(content)
        f.flush
        f.close
      end

      after do
        FileUtils.rm_r(filename)
      end

      it 'reads empty file correctly' do
        config = ConfigLoader.load_config(filename)
        expect(config).not_to be nil
        expect(config).to be_empty
      end

      it 'read file with options' do
        add_content(filename, "#{option}=#{value}")
        config = ConfigLoader.load_config(filename)
        expect(config).to include(option.to_sym => value)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jira_report-0.1.4 spec/jira_report/config_loader_spec.rb
jira_report-0.1.3 spec/jira_report/config_loader_spec.rb
jira_report-0.1.2 spec/jira_report/config_loader_spec.rb
jira_report-0.1.1 spec/jira_report/config_loader_spec.rb