forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout_test.rb
87 lines (77 loc) · 2.53 KB
/
layout_test.rb
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'test_helper'
describe "Repo layout" do
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
# todo: a more clever way to do this would be to dispense with
# the imperfect IGNORE lists and read the actual repo
# contents by reading the output of "git ls-files"
# dot dirs are always a project of Dir.entries
# other files are items that the developer hopefully has gitignored
IGNORE_FILES = %w{
.
..
.DS_Store
.bundle
.ruby-version
.rubocop_todo.yml
coverage
}
# the developer has hopefully gitignored these
IGNORE_REGEXPS = [
%r{~$}, # emacs
]
TOPLEVEL_DIRS = %w{
.git
Casks
bin
developer
doc
lib
spec
test
}
TOPLEVEL_FILES = %w{
.editorconfig
.gitattributes
.gitignore
.rspec
.rubocop.yml
.simplecov
.travis.yml
CONDUCT.md
CONTRIBUTING.md
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
USAGE.md
brew-cask.rb
}
describe "toplevel dir" do
it "finds some files at the top level" do
entries = Dir.entries(project_root)
entries.length.must_be :>, 0
end
it "only finds expected files at the top level" do
entries = Dir.entries(project_root) - IGNORE_FILES - TOPLEVEL_DIRS - TOPLEVEL_FILES
IGNORE_REGEXPS.each do |regexp|
entries.reject! { |elt| elt.match(regexp) }
end
entries.must_equal []
end
end
describe "Casks dir" do
it "finds some files in the Casks dir" do
entries = Dir.entries(project_root.join('Casks'))
entries.length.must_be :>, 0
end
it "only finds .rb files in the Casks dir" do
entries = Dir.entries(project_root.join('Casks')) - IGNORE_FILES
IGNORE_REGEXPS.each do |regexp|
entries.reject! { |elt| elt.match(regexp) }
end
entries.reject! { |elt| elt.match(%r{\.rb$}) }
entries.must_equal []
end
end
end