I play with Ruby Test::Unit::TestCase, and although my tests will run, pass, fail, etc. I do not see the points deduced for each test case. Is this the configuration I need to install, or the level of detail I need to specify?
I am running Ruby 2.1.0p0
For reference, here is the code I'm working with. This is from the Destroy All Software screencast, where the exercise is to build rspec from scratch (not all of this, of course):
Testing:
require 'test/unit'
require_relative 'spec'
class TestDescribe < Test::Unit::TestCase
def test_that_it_can_pass
describe 'some thing' do
it 'has some property' do
end
end
end
def test_that_it_can_fail
assert_raise(IndexError) do
describe 'some failing thing' do
it 'fails' do
raise IndexError
end
end
end
end
end
class TestAssertion < Test::Unit::TestCase
def test_that_it_can_pass
2.should == 2
end
def test_that_it_can_fail
assert_raise(AssertionError) do
1.should == 2
end
end
end
And the code:
def describe(description, &block)
ExampleGroup.new(block).evaluate!
end
class ExampleGroup
def initialize(block)
@block = block
end
def evaluate!
instance_eval(&@block)
end
def it(description, &block)
block.call
end
end
class Object
def should
DelayedAssertion.new(self)
end
end
class DelayedAssertion
def initialize(subject)
@subject = subject
end
def ==(other)
raise AssertionError unless @subject == other
end
end
class AssertionError < Exception
end
Exit at startup with ruby test_spec.rb
Run options:
Finished tests in 0.004410s, 907.0295 tests/s, 453.5147 assertions/s.
4 tests, 2 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
source
share