Sha256: 36e569f781dc25103301abd0a6b175b9db4e491902d2278084a4d8757d30ec30

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

module Pelusa
  describe Configuration do
    let(:configuration) do
      Pelusa::Configuration.new("#{FIXTURES_PATH}/sample_config_one.yml")
    end

    describe '#sources' do
      it 'returns path to sources' do
        configuration.sources.must_equal 'lib/**/*.rb'
      end

      describe 'by default' do
        it 'returns lib/**/*.rb' do
          empty_configuration = Pelusa::Configuration.new("unexistent_yml")
          empty_configuration.sources.must_equal Pelusa::Configuration::DEFAULT_SOURCES
        end
      end
    end

    describe '#enabled_lints' do
      let(:enabled_lints) { Lint.all - [ Pelusa::Lint::ElseClauses ] }

      it 'returns all enabled lints' do
        configuration.enabled_lints.must_equal(enabled_lints)
      end
    end

    describe '#[]' do
      describe 'when lint configuration exists' do
        let(:lint_configuration) { configuration['LineRestriction'] }

        it 'returns a configuration hash for the given lint' do
          lint_configuration.must_be_instance_of(Hash)
        end

        it 'must return valid configuration' do
          lint_configuration['limit'].must_equal(80)
        end
      end

      describe "when lint configuration doesn't exist" do
        let(:lint_configuration) { configuration['DemeterLaw'] }

        it 'returns an empty configuration hash' do
          lint_configuration.must_equal({})
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pelusa-0.2.4 test/pelusa/configuration_test.rb
pelusa-0.2.3 test/pelusa/configuration_test.rb
pelusa-0.2.2 test/pelusa/configuration_test.rb
pelusa-0.2.1 test/pelusa/configuration_test.rb
pelusa-0.2.0 test/pelusa/configuration_test.rb