[GH-2630] Bring in Minitest

This adds Minitest as a dependency and replaces the old `rake test`
by a Rake test runner.

Travis now includes the Minitest run before the Shindo run
This commit is contained in:
Paul Thornthwaite 2014-02-26 22:49:41 +00:00
parent 573591f8de
commit 18814bbefa
4 changed files with 14 additions and 49 deletions

View File

@ -1,4 +1,5 @@
require 'bundler/setup'
require 'rake/testtask'
require 'date'
require 'rubygems'
require 'rubygems/package_task'
@ -47,10 +48,11 @@ end
GEM_NAME = "#{name}"
task :default => :test
task :travis => ['test:travis', 'coveralls_push_workaround']
task :travis => ['test', 'test:travis', 'coveralls_push_workaround']
require "tasks/test_task"
Fog::Rake::TestTask.new
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
end
namespace :test do
mock = 'true' || ENV['FOG_MOCK']

View File

@ -54,6 +54,7 @@ Gem::Specification.new do |s|
## List your development dependencies here. Development dependencies are
## those that are only needed during development
s.add_development_dependency('minitest')
s.add_development_dependency('jekyll') unless RUBY_PLATFORM == 'java'
s.add_development_dependency('rake')
s.add_development_dependency('rbvmomi')

View File

@ -1,46 +0,0 @@
require "rake"
require "rake/tasklib"
module Fog
module Rake
class TestTask < ::Rake::TaskLib
def initialize
desc "Run the mocked tests"
task :test do
::Rake::Task[:mock_tests].invoke
end
task :mock_tests do
tests(true)
end
task :real_tests do
tests(false)
end
end
def tests(mocked)
Formatador.display_line
start = Time.now.to_i
threads = []
Thread.main[:results] = []
Fog.providers.each do |key, value|
threads << Thread.new do
Thread.main[:results] << {
:provider => value,
:success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
}
end
end
threads.each do |thread|
thread.join
end
Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
Formatador.display_line
end
end
end
end

8
test/hello_world_test.rb Normal file
View File

@ -0,0 +1,8 @@
require "minitest/autorun"
class HelloWorldTest < Minitest::Test
# This is a placeholder to ensure minitest is being picked up by rake
def test_truth
assert true
end
end