Sha256: ba905df7c7de2720c6ccf4b131a969de6b343a189025b10d15a1e61cc30a5a6d

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
rubycritic-2.6.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.5.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.4.1 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.4.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.3.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.2.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.1.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-2.0.0 test/lib/rubycritic/analysers/smells/flay_test.rb
rubycritic-1.4.0 test/lib/rubycritic/analysers/smells/flay_test.rb