Sha256: 883facd6557e44ed51ac72112d4787ef1b994ff6e0b8a006303bc63eee7492ea

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 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) { CONFIG_PATH.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

3 entries across 3 versions & 1 rubygems

Version Path
reek-4.8.2 spec/reek/spec/should_reek_spec.rb
reek-4.8.1 spec/reek/spec/should_reek_spec.rb
reek-4.8.0 spec/reek/spec/should_reek_spec.rb