Sha256: 4da64da27b54a3247f060d8da5a91f6cbfe0384e90485727eed161af6641c2e8
Contents?: true
Size: 799 Bytes
Versions: 2
Compression:
Stored size: 799 Bytes
Contents
module SimpleAssertions # Adds attribute matcher to +assert_raises+. # # == Example # # # old behaviour # assert_raises(StandardError) { ... } # # # exact match on attribute message # assert_raises(RuntimeError, :message => "yay!") do # raise "yay!" # end # # # pattern match on attributes # assert_raises(MyError, :message => /foo/, :code => 23) do # raise MyError, "foo bar", 23 # end module AssertRaises def assert_raises(*args, &block) attributes = args.last.is_a?(Hash) ? args.pop : {} exception = super(*args, &block).tap do |exception| attributes.each do |attribute, expected| actual = expected.send(attribute) assert_operator expected, :===, actual end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_assertions-0.2.0 | lib/simple_assertions/assert_raises.rb |
simple_assertions-0.1.0 | lib/simple_assertions/assert_raises.rb |