Slide 12
Slide 12 text
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