Sha256: 96d3e6ba82ca1f1c440cfa8a4d5c9bf70271211679009823a2b779ebe19729f4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require "analysers_test_helper"
require "rubycritic/analysers/smells/reek"

describe Rubycritic::Analyser::ReekSmells do
  context "when analysing a smelly file" do
    before do
      pathname = Pathname.new("test/samples/reek/smelly.rb")
      @analysed_module = AnalysedModuleDouble.new(:pathname => pathname, :smells => [])
      analysed_modules = [@analysed_module]
      Rubycritic::Analyser::ReekSmells.new(analysed_modules).run
    end

    it "detects its smells" do
      @analysed_module.smells.length.must_equal 1
    end

    it "creates smells with messages" do
      smell = @analysed_module.smells.first
      smell.message.must_equal "has boolean parameter 'reek'"
    end
  end

  context "when analysing a file with smells ignored in config.reek" do
    before do
      pathname = Pathname.new("test/samples/reek/not_smelly.rb")
      @analysed_module = AnalysedModuleDouble.new(:pathname => pathname, :smells => [])
      analysed_modules = [@analysed_module]
      Rubycritic::Analyser::ReekSmells.new(analysed_modules).run
    end

    it "does not detect those smells" do
      @analysed_module.smells.must_be_empty
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubycritic-2.1.0 test/lib/rubycritic/analysers/smells/reek_test.rb
rubycritic-2.0.0 test/lib/rubycritic/analysers/smells/reek_test.rb