From c3a72795ecab47f94527e079b60549051843caa4 Mon Sep 17 00:00:00 2001 From: pseudomuto Date: Wed, 18 Dec 2013 15:55:46 -0500 Subject: switching from test unit to minitest --- test/app_test.rb | 15 +++++++-------- test/cli_test.rb | 6 +++--- test/test_helper.rb | 23 ++++++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/app_test.rb b/test/app_test.rb index 0547eb8..a176d2e 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -1,11 +1,10 @@ require 'test_helper' require 'haml' -Sinatra::Application.settings.history_file = File.join(Dir.tmpdir, 'history.yml') - class AppTest < Dashing::Test def setup @connection = [] + Sinatra::Application.settings.history_file = File.join(Dir.tmpdir, 'history.yml') Sinatra::Application.settings.connections = [@connection] Sinatra::Application.settings.auth_token = nil Sinatra::Application.settings.default_dashboard = nil @@ -83,15 +82,15 @@ class AppTest < Dashing::Test with_generated_project do get '/sampletv' assert_equal 200, last_response.status - assert_include last_response.body, 'class="gridster"' - assert_include last_response.body, "DOCTYPE" + assert_includes last_response.body, 'class="gridster"' + assert_includes last_response.body, "DOCTYPE" end end def test_page_title_set_correctly with_generated_project do get '/sampletv' - assert_include last_response.body, '1080p dashboard' + assert_includes last_response.body, '1080p dashboard' end end @@ -100,7 +99,7 @@ class AppTest < Dashing::Test File.write(File.join(dir, 'dashboards/hamltest.haml'), '.gridster') get '/hamltest' assert_equal 200, last_response.status - assert_include last_response.body, "class='gridster'" + assert_includes last_response.body, "class='gridster'" end end @@ -110,7 +109,7 @@ class AppTest < Dashing::Test File.unlink(File.join(dir, 'widgets/clock/clock.html')) get '/views/clock.html' assert_equal 200, last_response.status - assert_include last_response.body, '

haml

' + assert_includes last_response.body, '

haml

' end end @@ -125,7 +124,7 @@ class AppTest < Dashing::Test with_generated_project do get '/views/meter.html' assert_equal 200, last_response.status - assert_include last_response.body, 'class="meter"' + assert_includes last_response.body, 'class="meter"' end end diff --git a/test/cli_test.rb b/test/cli_test.rb index 6c43e2c..2bf3b65 100644 --- a/test/cli_test.rb +++ b/test/cli_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -silent{ load 'bin/dashing' } +load_quietly 'bin/dashing' module Thor::Actions def source_paths @@ -12,7 +12,7 @@ class CliTest < Dashing::Test def test_project_directory_created temp do |dir| cli = Dashing::CLI.new - silent{ cli.new 'Dashboard' } + silent { cli.new 'Dashboard' } assert Dir.exist?(File.join(dir,'dashboard')), 'Dashing directory was not created.' end end @@ -25,4 +25,4 @@ class CliTest < Dashing::Test assert_equal 'super-power-rangers', Dashing::CLI.hyphenate('SuperPowerRangers') end -end \ No newline at end of file +end diff --git a/test/test_helper.rb b/test/test_helper.rb index b4bbd9e..9c51b87 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,20 +1,19 @@ require 'rack/test' require 'stringio' -require 'test/unit' require 'tmpdir' + +require 'minitest/autorun' +require 'minitest/pride' + require_relative '../lib/dashing' ENV['RACK_ENV'] = 'test' WORKING_DIRECTORY = Dir.pwd.freeze ARGV.clear -def silent - _stdout = $stdout - $stdout = mock = StringIO.new - begin - yield - ensure - $stdout = _stdout +def load_quietly(file) + Minitest::Test.new(nil).capture_io do + load file end end @@ -29,7 +28,13 @@ ensure end module Dashing - class Test < Test::Unit::TestCase + class Test < Minitest::Test include Rack::Test::Methods + + alias_method :silent, :capture_io + + def teardown + FileUtils.rm_f('history.yml') + end end end -- cgit v1.2.3