public
Created

spork+simplecove rails3.2

  • Download Gist
test_helper.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
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
test_prefork.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
 
 
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.