Browse Source

Add minimal test suite. Refs #291

master
Federico Bond 11 years ago
parent
commit
a35f2691ce
  1. 8
      Gemfile
  2. 19
      Gemfile.lock
  3. 8
      Rakefile
  4. 14
      test/Casks/compliance_test.rb
  5. 37
      test/test_helper.rb

8
Gemfile

@ -0,0 +1,8 @@
source 'https://rubygems.org'
group :test do
gem 'rake'
gem 'minitest', '5.3'
gem 'minitest-colorize'
gem 'mocha', '0.14.0', :require => false
end

19
Gemfile.lock

@ -0,0 +1,19 @@
GEM
remote: https://rubygems.org/
specs:
metaclass (0.0.4)
minitest (5.3.0)
minitest-colorize (0.0.5)
minitest (>= 2.0)
mocha (0.14.0)
metaclass (~> 0.0.1)
rake (10.3.2)
PLATFORMS
ruby
DEPENDENCIES
minitest (= 5.3)
minitest-colorize
mocha (= 0.14.0)
rake

8
Rakefile

@ -0,0 +1,8 @@
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
t.libs << 'test'
end
task :default => :test

14
test/Casks/compliance_test.rb

@ -0,0 +1,14 @@
require 'test_helper'
describe "Casks" do
Cask.all.reject {|c| c.is_a?(TestCask) }.each do |cask|
describe "#{cask}" do
it "passes audit" do
audit = Cask::Audit.new(cask)
audit.run!
audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
end
end
end
end

37
test/test_helper.rb

@ -0,0 +1,37 @@
require 'bundler'
require 'bundler/setup'
# add cask lib to load path
brew_cask_path = Pathname.new(File.expand_path(__FILE__+'/../../../homebrew-cask/'))
lib_path = brew_cask_path.join('lib')
$:.push(lib_path)
# add homebrew to load path
homebrew_path = Pathname(`brew --prefix`.chomp)
homebrew_path = Pathname('/usr/local') unless homebrew_path.exist?
$:.push(homebrew_path.join('Library', 'Homebrew'))
# require homebrew testing env
require 'test/testing_env'
# must be called after testing_env so at_exit hooks are in proper order
require 'minitest/autorun'
# todo, re-enable minitest-colorize, broken under current test environment for unknown reasons
# require 'minitest-colorize'
# our baby
require 'cask'
# pretend like we installed the cask tap
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
taps_dest = HOMEBREW_LIBRARY/"Taps/caskroom"
# create directories
FileUtils.mkdir_p taps_dest
HOMEBREW_PREFIX.join('bin').mkdir
FileUtils.ln_s project_root, taps_dest/"homebrew-cask"
# Common superclass for tests casks for when we need to filter them out
class TestCask < Cask; end
Loading…
Cancel
Save