Created
February 13, 2012 22:02
-
-
Save chetan/1820849 to your computer and use it in GitHub Desktop.
spork+simplecove rails3.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'spork' | |
#uncomment the following line to use spork with the debugger | |
#require 'spork/ext/ruby-debug' | |
Spork.prefork do | |
require File.expand_path(File.dirname(__FILE__)) + "/test_prefork" | |
end | |
Spork.each_run do | |
begin | |
require 'simplecov' | |
SimpleCov.start do | |
add_filter '/test/' | |
add_filter '/config/' | |
add_group 'Controllers', 'app/controllers' | |
add_group 'Models', 'app/models' | |
add_group 'Helpers', 'app/helpers' | |
add_group 'Libraries', 'lib' | |
end | |
# SimpleCov.at_exit do | |
# SimpleCov.result.format! | |
# end | |
rescue Exception => ex | |
end | |
ENV["BOOTSTRAPNOW"] = "1" | |
require "#{Rails.root.to_s}/config/initializers/mybootstrap" | |
end | |
# Spork.after_each_run do | |
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
require 'minitest/unit' | |
require 'turn' | |
require 'turn/reporter' | |
require 'turn/reporters/outline_reporter' | |
Turn.config.framework = :minitest | |
Turn.config.format = :outline | |
module Turn | |
class OutlineReporter < Reporter | |
def start_test(test) | |
@stdout = StringIO.new | |
@stderr = StringIO.new | |
name = naturalized_name(test) | |
io.print " %-57s" % name | |
@stdout.rewind | |
@stderr.rewind | |
$stdout = @stdout | |
$stderr = @stderr unless $DEBUG | |
end | |
end | |
end | |
if $0 == __FILE__ then | |
# require all test cases if not running via rake | |
$: << File.expand_path(File.dirname(__FILE__)) | |
Dir.glob(File.expand_path(File.dirname(__FILE__)) + "/**/*.rb").each do |f| | |
next if f =~ /test\/performance/ or f == File.expand_path(__FILE__) | |
require f | |
end | |
end | |
# load curb first so webmock can stub it out as necessary | |
require 'curb' | |
require 'webmock' | |
include WebMock::API | |
require 'mocha' | |
class ActiveSupport::TestCase | |
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. | |
# | |
# Note: You'll currently still have to declare fixtures explicitly in integration tests | |
# -- they do not yet inherit this setting | |
fixtures :all | |
# Add more helper methods to be used by all tests here... | |
end | |
class MiniTest::Unit::TestCase | |
# minitest assert_throws doesn't seem to work properly | |
def assert_throws(clazz, msg = nil, &block) | |
begin | |
yield | |
rescue Exception => ex | |
puts "#{ex.class}: #{ex.message}" | |
puts ex.backtrace.join("\n") | |
if clazz.to_s == ex.class.name then | |
if msg.nil? | |
return | |
elsif msg == ex.message then | |
return | |
end | |
end | |
end | |
flunk("Expected #{mu_pp(clazz)} to have been thrown") | |
end | |
end | |
MiniTest::Unit.autorun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment