Sha256: 6be4cedbf45daca62d8e0815bdf4445cd8dfe0cf1354e31abdb212821113a1e6

Contents?: true

Size: 954 Bytes

Versions: 7

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/churn'
require 'rubycritic/source_control_systems/base'

describe RubyCritic::Analyser::Churn do
  context 'when analysing a file' do
    before do
      @analysed_module = AnalysedModuleDouble.new(path: 'path_to_some_file.rb')
      analysed_modules = [@analysed_module]
      analyser = RubyCritic::Analyser::Churn.new(analysed_modules)
      analyser.source_control_system = SourceControlSystemDouble.new
      analyser.run
    end

    it 'calculates its churn' do
      @analysed_module.churn.must_equal 1
    end

    it 'determines the date of its last commit' do
      @analysed_module.committed_at.must_equal '2013-10-09 12:52:49 +0100'
    end
  end
end

class SourceControlSystemDouble < RubyCritic::SourceControlSystem::Base
  def revisions_count(_path)
    1 # churn
  end

  def date_of_last_commit(_path)
    '2013-10-09 12:52:49 +0100'
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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