Sha256: 0480cb47865f2cbb2fe4cb2e39f3a0628c19db8be0370db1f007eae045765e24

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

require_relative '../../spec_helper'
require_lib 'reek/spec'

RSpec.describe Reek::Spec::ShouldReek do
  describe 'checking code in a string' do
    let(:matcher) { described_class.new }
    let(:clean_code) { 'def good() true; end' }
    let(:smelly_code) { 'def x() y = 4; end' }

    it 'matches a smelly String' do
      expect(matcher).to be_matches(smelly_code)
    end

    it 'doesnt match a fragrant String' do
      expect(matcher).not_to be_matches(clean_code)
    end

    it 'reports the smells when should_not fails' do
      matcher.matches?(smelly_code)
      expect(matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
    end
  end

  describe 'checking code in a File' do
    context 'without masking' do
      let(:matcher) { described_class.new }

      it 'matches a smelly File' do
        expect(matcher).to be_matches(SMELLY_FILE)
      end

      it 'doesnt match a fragrant File' do
        expect(matcher).not_to be_matches(CLEAN_FILE)
      end

      it 'reports the smells when should_not fails' do
        matcher.matches?(SMELLY_FILE)
        expect(matcher.failure_message_when_negated).to match('UncommunicativeMethodName')
      end
    end

    context 'with masking' do
      let(:path) { CONFIGURATION_DIR.join('full_mask.reek') }
      let(:configuration) { test_configuration_for(path) }
      let(:matcher) { described_class.new(configuration: configuration) }

      it 'masks smells using the relevant configuration' do
        expect(matcher).not_to be_matches(SMELLY_FILE)
      end
    end
  end
end

Version data entries

20 entries across 18 versions & 2 rubygems

Version Path
reek-6.0.3 spec/reek/spec/should_reek_spec.rb
reek-6.0.2 spec/reek/spec/should_reek_spec.rb
reek-6.0.1 spec/reek/spec/should_reek_spec.rb
reek-6.0.0 spec/reek/spec/should_reek_spec.rb
reek-5.6.0 spec/reek/spec/should_reek_spec.rb
reek-5.5.0 spec/reek/spec/should_reek_spec.rb
reek-5.4.1 spec/reek/spec/should_reek_spec.rb
reek-5.4.0 spec/reek/spec/should_reek_spec.rb
reek-5.3.2 spec/reek/spec/should_reek_spec.rb
reek-5.3.1 spec/reek/spec/should_reek_spec.rb
reek-5.3.0 spec/reek/spec/should_reek_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/spec/should_reek_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/spec/should_reek_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/spec/should_reek_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/spec/should_reek_spec.rb
reek-5.2.0 spec/reek/spec/should_reek_spec.rb
reek-5.1.0 spec/reek/spec/should_reek_spec.rb
reek-5.0.2 spec/reek/spec/should_reek_spec.rb
reek-5.0.1 spec/reek/spec/should_reek_spec.rb
reek-5.0.0 spec/reek/spec/should_reek_spec.rb