This is the very simple Verify mini test framework
It emphasises on being able to check things out quickly without having to load a heavy test framework. It evolves around my needs but for the time being it is pretty lightweight.
require ‘verify’
Verify “Some Important Facts” do verify “42 is true” do 42 end refute “42 is pretty big” do 42 > 100_000 end verify_exceptions NoMethodError do 42.unrelinguished! end end
These forms are very easy to remember, but sometimes one needs to see where the errors, are, in order to achieve that one can use the parameter form
Verify “With parameters” do verify msg: “Everything is well”, target: 42, actual: 21 * 2 refute msg: “But not too much”, target: 42, actual: 41 end
Mockify allows to capture stdout or simulate stdin, all you need to do is to require ‘mockify’ before requiring ‘verify’ and than you can provide stdin and get stdout
Verify “Providing stdin” do with_input %wQuick Brown Fox do verify %line is “The” do “The” == gets.chomp end end end
Verify “Capturing stdout” do out = with_output do | o | puts 42 verify target: “42n”, actual: o.string end end verify msg: “with_output converted out to an array of lines”, actual: out.map( &:chomp ), target: %w{ 42 } end
Enjoy