Sha256: eb26ff179d2d57aa9f5e5e66e11fd25e15efd58baf4ad3ba5a799bd1c5edcf42

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true
require 'test_helper'
require 'rubycritic/analysers/smells/flay'
require 'rubycritic/core/analysed_module'
require 'pathname'

describe RubyCritic::Analyser::FlaySmells do
  context 'when analysing a bunch of files with duplicate code' do
    before do
      @analysed_modules = [
        RubyCritic::AnalysedModule.new(pathname: Pathname.new('test/samples/flay/smelly.rb')),
        RubyCritic::AnalysedModule.new(pathname: Pathname.new('test/samples/flay/smelly2.rb'))
      ]
      RubyCritic::Analyser::FlaySmells.new(@analysed_modules).run
    end

    it 'detects its smells' do
      @analysed_modules.first.smells?.must_equal true
    end

    it 'creates smells with messages' do
      smell = @analysed_modules.first.smells.first
      smell.message.must_be_instance_of String
    end

    it 'creates smells with scores' do
      smell = @analysed_modules.first.smells.first
      smell.score.must_be_kind_of Numeric
    end

    it 'creates smells with more than one location' do
      smell = @analysed_modules.first.smells.first
      smell.multiple_locations?.must_equal true
    end

    it 'calculates the mass of duplicate code' do
      @analysed_modules.first.duplication.must_be(:>, 0)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-3.2.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-3.1.3 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-3.1.2 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-3.1.1 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-3.1.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-3.0.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.9.4 test/lib/rubycritic/analysers/smells/flay_test.rb