Sha256: f0b34a8a49af78f2e5ce8f2870bb2149d6335244a73eeb1bcf64a3c2ab3e9f75

Contents?: true

Size: 1.72 KB

Versions: 31

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

module SCSSLint
  describe Plugins::LinterGem do
    let(:subject) { described_class.new('a_gem') }

    describe '#load' do
      let(:gem_dir) { '/gem_dir' }
      let(:config_file) { File.join(gem_dir, '.scss-lint.yml') }
      let(:config_file_exists) { false }

      before do
        File.stub(:exist?).with(config_file).and_return(config_file_exists)
      end

      context 'when the gem does not exist' do
        it 'raises an exception' do
          expect { subject.load }.to raise_error Exceptions::PluginGemLoadError
        end
      end

      context 'when the gem exists' do
        before do
          subject.stub(:require).with('a_gem').and_return(true)
          Gem::Specification.stub(:find_by_name)
                            .with('a_gem')
                            .and_return(double(gem_dir: gem_dir))
        end

        it 'requires the gem' do
          subject.should_receive(:require).with('a_gem').once
          subject.load
        end

        context 'when the gem does not include a configuration file' do
          it 'loads an empty configuration' do
            subject.load
            subject.config.should == Config.new({})
          end
        end

        context 'when a config file exists in the gem' do
          let(:config_file_exists) { true }
          let(:fake_config) { Config.new('linters' => { 'FakeLinter' => {} }) }

          before do
            Config.should_receive(:load)
                  .with(config_file, merge_with_default: false)
                  .and_return(fake_config)
          end

          it 'loads the configuration' do
            subject.load
            subject.config.should == fake_config
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
scss_lint-0.60.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.59.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.58.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.57.1 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.57.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.56.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.55.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.54.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.53.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.52.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.51.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.50.3 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.50.2 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.50.1 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.50.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.49.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.48.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.47.1 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.47.0 spec/scss_lint/plugins/linter_gem_spec.rb
scss_lint-0.46.0 spec/scss_lint/plugins/linter_gem_spec.rb