Sha256: 3ba83a14e92f1b2c57e7fce1653e029ef8db879f6ea289d79365f5adbdab3422

Contents?: true

Size: 1.75 KB

Versions: 8

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe Codeqa::Configuration do
  let(:subject){ Codeqa.configuration }

  it 'should be exposed in the Codeqa module' do
    expect(Codeqa).to respond_to(:configuration)
  end

  %w(excludes enabled_checker erb_engine rubocop_formatter_cops).each do |c|
    it "should provide :#{c}" do
      expect(Codeqa.configuration).to respond_to(c.to_sym)
    end
  end

  it 'should have the excludes set' do
    expect(Codeqa.configuration.excludes).to be_a(Set)
    expect(Codeqa.configuration.excludes).to eq(Set.new(['vendor/**/*']))
  end
  it 'should have the enabled checkers set' do
    expect(Codeqa.configuration.enabled_checker).to be_a(Set)
    exp_set = Set.new(%w(CheckStrangeChars
                         CheckUtf8Encoding
                         CheckConflict
                         CheckPry
                         RubocopLint))
    expect(Codeqa.configuration.enabled_checker).to eq(exp_set)
  end

  context 'exclude' do
    before(:each) do
      @org_dir = Dir.pwd
      project_root = Codeqa.root.join 'spec/fixtures/isolation/home/project'
      allow(Codeqa.configuration).to receive(:project_root).and_return(Pathname.new(project_root))
      Dir.chdir(project_root)
      Codeqa.configure{ |c| c.excludes = ['ignored/*', /tmp/] }
    end
    after(:each) do
      Dir.chdir(@org_dir)
      load_test_config
    end
    it 'should be true for filenames within a foo folder' do
      expect(Codeqa.configuration.excluded?('ignored/some_file.txt')).to be true
    end
    it 'should be false for files unrelated to the excludes' do
      expect(Codeqa.configuration.excluded?('file.rb')).to be false
    end
    it 'should work with regex matches' do
      expect(Codeqa.configuration.excluded?('some/tmp/path')).to be true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
codeqa-0.5.0 spec/lib/codeqa/configuration_spec.rb
codeqa-0.4.2 spec/lib/codeqa/configuration_spec.rb
codeqa-0.4.1 spec/lib/codeqa/configuration_spec.rb
codeqa-0.4.0 spec/lib/codeqa/configuration_spec.rb
codeqa-0.4.0.pre2 spec/lib/codeqa/configuration_spec.rb
codeqa-0.4.0.pre spec/lib/codeqa/configuration_spec.rb
codeqa-0.3.1 spec/lib/codeqa/configuration_spec.rb
codeqa-0.3.0 spec/lib/codeqa/configuration_spec.rb