Я разветвляюсь из rspec и попадаю в MiniTest и shoulda. Я не могу понять, как методы испытаний работать с Shoulda ...Методы тестирования отчетов MiniTest/Shoulda и Shoulda/Context?
class TestKata < MiniTest::Test
context 'Kata#n00bify' do
should 'replace "to" and "too" with the number 2, even if
they are only part of a word (E.g. today = 2day)' do
assert_equal '2', Kata.n00bify('too')
assert_equal '2', Kata.n00bify('too')
assert_equal '2day', Kata.n00bify('today')
end
should 'replace "for" and "fore" with the number 4' do
assert_equal '4', Kata.n00bify('for')
assert_equal '4', Kata.n00bify('fore')
end
# ...
end
end
Вот результаты теста:
Failure: TestKata#test_: Kata#n00bify should replace "for" and "fore" with the number 4. [/.../test_n00b.rb:31] Minitest::Assertion: Expected: "4" Actual: nil Failure: TestKata#test_: Kata#n00bify should replace "to" and "too" with the number 2, even if they are only part of a word (E.g. today = 2day). [/.../test_n00b.rb:25] Minitest::Assertion: Expected: "2" Actual: nil
Дело в том, что я не понимаю, - где методы испытаний? Обратите внимание, что в результатах теста TestKata#test_<nothing>:
. Кажется уродливым для меня. Хотелось бы, чтобы он читался только с учетом контекста. то есть:
Failure: Kata#n00bify should ...
Что мне не хватает? Цените помощь!