Sha256: c4cd46042d92f4dabcba2e5bb5024dcb1eda72c14acc8fdec18322f8bc03cea7

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 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) { Reek::Spec::ShouldReek.new }
    let(:clean_code) { 'def good() true; end' }
    let(:smelly_code) { 'def x() y = 4; end' }

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

    it 'doesnt match a fragrant String' do
      expect(matcher.matches?(clean_code)).to be_falsey
    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 'matcher without masking' do
      let(:matcher) { Reek::Spec::ShouldReek.new }

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

      it 'doesnt match a fragrant File' do
        expect(matcher.matches?(CLEAN_FILE)).to be_falsey
      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 'matcher without masking' do
      let(:path) { CONFIG_PATH.join('full_mask.reek') }
      let(:configuration) { test_configuration_for(path) }
      let(:matcher) { Reek::Spec::ShouldReek.new(configuration: configuration) }

      it 'masks smells using the relevant configuration' do
        expect(matcher.matches?(SMELLY_FILE)).to be_falsey
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reek-4.4.1 spec/reek/spec/should_reek_spec.rb
reek-4.4.0 spec/reek/spec/should_reek_spec.rb
reek-4.3.0 spec/reek/spec/should_reek_spec.rb
reek-4.2.5 spec/reek/spec/should_reek_spec.rb
reek-4.2.4 spec/reek/spec/should_reek_spec.rb