Module: XMP2Assert::Assertions
- Includes:
- Test::Unit::Assertions, XMP2Rexp
- Defined in:
- lib/xmp2assert/assertions.rb
Overview
Helper module that implements assertions.
Instance Method Summary collapse
-
#assert_capture2e(expected, script, message = nil, rubyopts: nil, **opts) ⇒ Object
Run a ruby script and assert for its output.
-
#assert_xmp(xmp, expr, message = nil) ⇒ Object
Assert if the given expression is in the same form of xmp.
Methods included from XMP2Rexp
Instance Method Details
#assert_capture2e(expected, script, message = nil, rubyopts: nil, **opts) ⇒ Object
Note:
As the method name implies the assertion is against both stdin and stderr at once. This is for convenience.
Run a ruby script and assert for its output.
assert_capture2e "foo\n", Quasifile.new("puts 'foo'")
54 55 56 57 58 |
# File 'lib/xmp2assert/assertions.rb', line 54 def assert_capture2e expected, script, = nil, rubyopts: nil, **opts actual, _ = ruby script, rubyopts: rubyopts, **opts actual.force_encoding expected.encoding return assert_xmp_raw expected, actual, end |
#assert_xmp(xmp, expr, message = nil) ⇒ Object
Assert if the given expression is in the same form of xmp.
assert_xmp '#<Object:0x007f896c9b49c8>', Object.new
69 70 71 |
# File 'lib/xmp2assert/assertions.rb', line 69 def assert_xmp xmp, expr, = nil assert_xmp_raw xmp, expr.inspect, end |