2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "abstract_unit"
|
|
|
|
require "rails/code_statistics"
|
2015-04-09 03:48:01 -04:00
|
|
|
|
|
|
|
class CodeStatisticsTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
2017-05-15 10:17:28 -04:00
|
|
|
@tmp_path = File.expand_path("fixtures/tmp", __dir__)
|
2016-08-06 13:16:09 -04:00
|
|
|
@dir_js = File.join(@tmp_path, "lib.js")
|
2015-04-09 03:48:01 -04:00
|
|
|
FileUtils.mkdir_p(@dir_js)
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
FileUtils.rm_rf(@tmp_path)
|
|
|
|
end
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
test "ignores directories that happen to have source files extensions" do
|
2015-04-09 03:48:01 -04:00
|
|
|
assert_nothing_raised do
|
2016-08-06 13:16:09 -04:00
|
|
|
@code_statistics = CodeStatistics.new(["tmp dir", @tmp_path])
|
2015-04-09 03:48:01 -04:00
|
|
|
end
|
|
|
|
end
|
2016-01-11 02:42:23 -05:00
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
test "ignores hidden files" do
|
|
|
|
File.write File.join(@tmp_path, ".example.rb"), <<-CODE
|
2016-01-11 02:42:23 -05:00
|
|
|
def foo
|
|
|
|
puts 'foo'
|
|
|
|
end
|
|
|
|
CODE
|
|
|
|
|
|
|
|
assert_nothing_raised do
|
2016-08-06 13:16:09 -04:00
|
|
|
CodeStatistics.new(["hidden file", @tmp_path])
|
2016-01-11 02:42:23 -05:00
|
|
|
end
|
|
|
|
end
|
2015-04-09 03:48:01 -04:00
|
|
|
end
|