Sha256: 164d1ef5f7b1083e4744b933302b34a996f37458ed3fd837f46da8b44a0d4350

Contents?: true

Size: 924 Bytes

Versions: 6

Compression:

Stored size: 924 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-2.9.2 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-2.9.1 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-2.9.0 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-2.8.0 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-2.7.1 test/lib/rubycritic/analysers/churn_test.rb
rubycritic-2.7.0 test/lib/rubycritic/analysers/churn_test.rb