Sha256: a5c2d3b6270327ef3fe0e0c1c0656cae7b9ccf2d1327169c11fa88e74cbe2935
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::ConfigStore do subject(:config_store) { described_class.new } before do Rubocop::Config.stub(:configuration_file_for) do |arg| # File tree: # file1 # dir/.rubocop.yml # dir/file2 # dir/subdir/file3 (arg =~ /dir/ ? 'dir' : '.') + '/.rubocop.yml' end Rubocop::Config.stub(:configuration_from_file) { |arg| arg } Rubocop::Config.stub(:load_file) { |arg| "#{arg} loaded" } Rubocop::Config.stub(:merge_with_default) do |config, file| "merged #{config}" end end describe '.for' do it 'always uses config specified in command line' do config_store.set_options_config(:options_config) expect(config_store.for('file1')).to eq('merged options_config loaded') end context 'when no config specified in command line' do it 'gets config path and config from cache if available' do Rubocop::Config.should_receive(:configuration_file_for).once .with('dir') Rubocop::Config.should_receive(:configuration_file_for).once .with('dir/subdir') # The stub returns the same config path for dir and dir/subdir. Rubocop::Config.should_receive(:configuration_from_file).once .with('dir/.rubocop.yml') config_store.for('dir/file2') config_store.for('dir/file2') config_store.for('dir/subdir/file3') end it 'searches for config path if not available in cache' do Rubocop::Config.should_receive(:configuration_file_for).once Rubocop::Config.should_receive(:configuration_from_file).once config_store.for('file1') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.14.0 | spec/rubocop/config_store_spec.rb |