Petitest::Assertions
Assertions for Petitest.
Installation
Add this line to your application's Gemfile:
gem "petitest-assertions"
And then execute:
bundle
Or install it yourself as:
gem install petitest-assertions
Usage
Setup
- Require
"petitest/assertions"
- Include
Petitest::Assertions
into your test groups
require "petitest/autorun"
require "petitest/assertions"
class ExampleTest < Petitest::TestGroup
include ::Petitest::Assertions
# ... test cases ...
end
assert_equal
assert_equal(2, 1 + 1)
assert_match
assert_match(/foo/, "fooooo")
assert_operator
assert_operator(2, :>, 1)
assert_output
assert_output(/foo/, nil) do
puts "fooooo"
end
assert_output(nil, /foo/) do
$stdout.puts "fooooo"
end
assert_output(/foo/, /bar/) do
puts "fooooo"
$stdout.puts "barrrr"
end
assert_raise
assert_raise(::StandardError) do
raise
end
assert_to_be
assert_to_be(:empty, [])
assert_to_have
assert_to_have(:key, :foo, foo: :bar)