Sha256: 31c2f980335c5fee2cafc04d063bbf6016a31402b6f27aa73d48513a57455aae

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 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

5 entries across 5 versions & 1 rubygems

Version Path
rubycritic-3.4.0 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-3.3.0 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-3.2.3 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-3.2.2 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-3.2.1 test/lib/rubycritic/analysers/churn_test.rb