require "minitest/autorun" class Person def hello; 'hello' end end class TestPerson < Minitest::Test def setup @person = Person.new end def test_hello assert_equal "hello", @person.hello end end likes test-unit
likes RSpec require "minitest/autorun" class Person def hello; 'hello' end end describe Person do before do @person = Person.new end it 'should say hello' do @person.hello.must_equal 'hello' end end
class MyMatcher def initialize(text) @text = text end def matches? subject subject =~ /^#{@text}.*/ end def failure_message_for_should "expected to start with #{@text}" end def failure_message_for_should_not "expected not to start with #{@text}" end end MiniTest::Unit::TestCase.register_matcher MyMatcher, :start_with describe 'something' do it 'must start with...' do page = 'my reply' page.must_start_with 'my reply' end end minitest-matchers
describe 'ߘϖʔδʹભҠ͍ͯ͠Δͱ͖' do before { visit posts_path } it '"ߘ͢Δ"ϘλϯΛԡͨ͠Β"ߘ͠·ͨ͠"ͱදࣔ͞Ε͍ͯΔ͜ͱ' do click_button 'ߘ͢Δ' page.text.must_include 'ߘ͠·ͨ͠' end it '"আ͢Δ"ϘλϯΛԡͨ͠Β confirm ͕දࣔ͞Ε͍ͯΔ͜ͱ', js: true do click_button 'আ͢Δ' page.driver.confirm_messages.wont_be_empty end end minitest-metadata