Sha256: 0c967d32ad979739f3bb373d73b050bfa3d3bec0e67f2c879a4f0d0aa3522362

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

require 'rspec'
require 'gherkin_lint/configuration'
require 'shared_contexts/file_exists'

describe GherkinLint::Configuration do
  subject { GherkinLint::Configuration.new file }
  let(:file) { 'default.yml' }

  it 'should do something' do
    expect(subject.config).to eq('')
  end

  it 'should have a default config path' do
    expect(subject.configuration_path).not_to be nil
  end
  context 'when a empty config file is present' do
    include_context 'a file exists'
    let(:file_content) { '---' }
    it 'should load a file from the config path' do
      expect(subject.config).to eq ''
    end
  end

  context 'when a non-YAML config file is present' do
    include_context 'a file exists'
    let(:file_content) do
      <<-content
      foo: [
        ‘bar’, {
          baz: 42
         }
      ]'
      content
    end

    it 'should load a file from the config path but fail to parse' do
      expect { subject.load_configuration }.to raise_error
      expect { subject.config }.to raise_error
    end
  end
  context 'when a valid YAML file is present' do
    include_context 'a file exists'
    let(:file_content) do
      <<-content
---
:parent_key: parent_value
:child_key: child_value
      content
    end
    before :each do
      subject.load_configuration
    end

    it 'should load the values from the config file' do
      expect(subject.config).to eq(parent_key: 'parent_value', child_key: 'child_value')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gherkin_lint-1.2.2 spec/configuration_spec.rb
gherkin_lint-1.2.1 spec/configuration_spec.rb
gherkin_lint-1.1.0 spec/configuration_spec.rb
gherkin_lint-1.0.0 spec/configuration_spec.rb