diff options
| author | AnastasiaSulyagina | 2016-08-18 22:40:05 +0300 |
|---|---|---|
| committer | AnastasiaSulyagina | 2016-08-19 14:50:27 +0300 |
| commit | 092e2797e156a36acd750d2783a18b47305a9747 (patch) | |
| tree | fbe7354cc4a98158a53c56f317e8419dae3fd883 /Library/Homebrew/cask/test | |
| parent | e81f4ab7deeb40308f240be5ea00091fc8786d7a (diff) | |
| download | brew-092e2797e156a36acd750d2783a18b47305a9747.tar.bz2 | |
edits
Diffstat (limited to 'Library/Homebrew/cask/test')
| -rw-r--r-- | Library/Homebrew/cask/test/cask_test.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/layout_test.rb | 94 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/test_helper.rb | 3 |
3 files changed, 7 insertions, 99 deletions
diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb index 05bdb6eff..64fc21965 100644 --- a/Library/Homebrew/cask/test/cask_test.rb +++ b/Library/Homebrew/cask/test/cask_test.rb @@ -1,6 +1,7 @@ require "test_helper" describe "Cask" do + hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask" describe "load" do it "returns an instance of the Cask for the given token" do c = Hbc.load("adium") @@ -9,14 +10,14 @@ describe "Cask" do end it "returns an instance of the Cask from a specific file location" do - location = File.expand_path("./Casks/dia.rb") + location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") c = Hbc.load(location) c.must_be_kind_of(Hbc::Cask) c.token.must_equal("dia") end it "returns an instance of the Cask from a url" do - url = "file://" + File.expand_path("./Casks/dia.rb") + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") c = shutup do Hbc.load(url) end @@ -26,7 +27,7 @@ describe "Cask" do it "raises an error when failing to download a Cask from a url" do lambda { - url = "file://" + File.expand_path("./Casks/notacask.rb") + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") shutup do Hbc.load(url) end @@ -34,7 +35,7 @@ describe "Cask" do end it "returns an instance of the Cask from a relative file location" do - c = Hbc.load("./Casks/bbedit.rb") + c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") c.must_be_kind_of(Hbc::Cask) c.token.must_equal("bbedit") end diff --git a/Library/Homebrew/cask/test/layout_test.rb b/Library/Homebrew/cask/test/layout_test.rb deleted file mode 100644 index 110725f31..000000000 --- a/Library/Homebrew/cask/test/layout_test.rb +++ /dev/null @@ -1,94 +0,0 @@ -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 - .rubocop.yml - .rubocop_todo.yml - .ruby-version - coverage - vendor - ].freeze - - # the developer has hopefully gitignored these - IGNORE_REGEXPS = [ - %r{~$}, # emacs - %r{.sublime-\w+}, # Sublime Text - ].freeze - - TOPLEVEL_DIRS = %w[ - .git - .github - Casks - Formula - ci - cmd - developer - doc - lib - man - spec - test - ].freeze - - TOPLEVEL_FILES = %w[ - .editorconfig - .gitattributes - .gitignore - .rspec - .rubocop.yml - .simplecov - .travis.yml - CONDUCT.md - CONTRIBUTING.md - Gemfile - Gemfile.lock - LICENSE - README.md - Rakefile - tap_migrations.json - USAGE.md - ].freeze - - 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 diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index dfe2484ed..528ca69cf 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -8,6 +8,7 @@ if ENV["COVERAGE"] end project_root = Pathname.new(File.expand_path("../..", __FILE__)) +tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask") # add Homebrew to load path $LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew")) @@ -78,7 +79,7 @@ Hbc.default_tap = Tap.fetch("caskroom", "testcasks") FileUtils.ln_s project_root.join("test", "support"), Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-testcasks") # pretend that the caskroom/cask Tap is installed -FileUtils.ln_s project_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask") +FileUtils.ln_s tap_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask") # create cache directory Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache") |
