Sha256: 8f21de5b077ea9e251d7e6723d9754a07f7d86dad300762cac91e8f98ca38c57

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'test_helper'

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

    describe "#present?" do
      it "returns false when configuration doesn't file exists" do
        configuration = Pelusa::Configuration.new("#{FIXTURES_PATH}/not_here.yml")
        configuration.present?.must_equal(false)
      end

      it "returns false when configuration file exists" do
        configuration.present?.must_equal(true)
      end
    end

    describe '#sources' do
      it 'returns path to sources' do
        configuration.sources.must_equal 'lib/**/*.rb'
      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

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.1.0 test/pelusa/configuration_test.rb