aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/code_statistics_test.rb
blob: 4d80901217792e54eb6a219e76f6e78ad29ddea4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'abstract_unit'
require 'rails/code_statistics'

class CodeStatisticsTest < ActiveSupport::TestCase
  def setup
    @tmp_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'tmp'))
    @dir_js   = File.join(@tmp_path, 'lib.js')
    FileUtils.mkdir_p(@dir_js)
  end

  def teardown
    FileUtils.rm_rf(@tmp_path)
  end

  test 'ignores directories that happen to have source files extensions' do
    assert_nothing_raised do
      @code_statistics = CodeStatistics.new(['tmp dir', @tmp_path])
    end
  end

  test 'ignores hidden files' do
    File.write File.join(@tmp_path, '.example.rb'), <<-CODE
      def foo
        puts 'foo'
      end
    CODE

    assert_nothing_raised do
      CodeStatistics.new(['hidden file', @tmp_path])
    end
  end

end