Method: LibGems::Validator#unit_test
- Defined in:
- lib/libgems/validator.rb
#unit_test(gem_spec) ⇒ Object
Runs unit tests for a given gem specification
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/libgems/validator.rb', line 199 def unit_test(gem_spec) start_dir = Dir.pwd Dir.chdir(gem_spec.full_gem_path) $: << gem_spec.full_gem_path # XXX: why do we need this gem_spec when we've already got 'spec'? test_files = gem_spec.test_files if test_files.empty? then say "There are no unit tests to run for #{gem_spec.full_name}" return nil end gem gem_spec.name, "= #{gem_spec.version.version}" test_files.each do |f| require f end if RUBY_VERSION < '1.9' then suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}") ObjectSpace.each_object(Class) do |klass| suite << klass.suite if (klass < Test::Unit::TestCase) end result = TestRunner.run suite, ui alert_error result.to_s unless result.passed? else result = MiniTest::Unit.new result.run end result ensure Dir.chdir(start_dir) end |