Sha256: f8d61a29a4d87a6e7eb817a3ce2aac1aad561c22f4393535855dc28ac6f8a48d

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
require 'reek/cli/application'

include Reek::Cli
include Reek::Configuration

describe ConfigurationFileFinder do
  describe '.find' do
    let(:sample_config_path) { Pathname.new('spec/samples/simple_configuration.reek') }
    let(:config_path_same_level) { Pathname.new('spec/samples/simple_configuration.reek') }
    let(:options_with_config_file) { double(config_file: sample_config_path) }
    let(:options_without_config_file) { double(config_file: nil) }

    it 'should return the config file we passed as cli option if given' do
      expect(ConfigurationFileFinder.find(options_with_config_file)).to eq(sample_config_path)
    end

    it 'should return the first configuration file it can find in the current directory' do
      allow(ConfigurationFileFinder).to receive(:detect_or_traverse_up).
        and_return config_path_same_level

      expect(ConfigurationFileFinder.find(options_without_config_file)).
        to eq(config_path_same_level)
    end

    it 'should look in the HOME directory lastly' do
      allow(ConfigurationFileFinder).to receive(:configuration_by_cli).and_return nil
      allow(ConfigurationFileFinder).to receive(:configuration_in_file_system).and_return nil
      expect(ConfigurationFileFinder).to receive(:configuration_in_home_directory).once

      ConfigurationFileFinder.find nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reek-2.0.4 spec/reek/configuration/configuration_file_finder_spec.rb
reek-2.0.3 spec/reek/configuration/configuration_file_finder_spec.rb
reek-2.0.2 spec/reek/configuration/configuration_file_finder_spec.rb
reek-2.0.1 spec/reek/configuration/configuration_file_finder_spec.rb
reek-2.0.0 spec/reek/configuration/configuration_file_finder_spec.rb