From: Alex Chaffee Date: 2011-10-14T05:42:36+09:00 Subject: [ANN] Wrong 0.6.0 released --001636c927fcc85db904af342d02 Content-Type: text/plain; charset=ISO-8859-1 New with this version: * "eventually" method for async polling assertions * "d" takes an optional message Full docs in the README at https://github.com/sconover/wrong --- Wrong provides a simple assert method that takes a block, and understands the code inside it, providing verbose failure messages for free. require "wrong" include Wrong assert { 1 == 1 } #=> nil assert { 2 == 1 } #=> Expected (2 == 1), but 2 is not equal to 1 There are also some helper methods: "rescuing" for catching exceptions: assert{ rescuing{raise "vanilla"}.message == "chocolate" } "capturing" for stdout/stderr: assert { capturing { puts "hi" } == "hi\n" } assert { capturing(:stderr) { $stderr.puts "hi" } == "hi\n" } "d" for debugging: x = 7 d { x } # => prints "x is 7" to the console d { x * 2 } # => prints "(x * 2) is 14" to the console d("math is hard") { 2 + 2 } #=> prints "math is hard: (2 + 2) is 4" "close_to?" for floating point comparison assert { 5.0.close_to?(5.0001) } # default tolerance = 0.001 assert { 5.0.close_to?(5.1, 0.5) } # optional tolerance parameter "eventually" for async polling: eventually { night? } calls night? N times a second, returning the first time it's true(ish), or raising an error after M seconds (default N=4 and M=5) -- Alex Chaffee - alex@cohuman.com - http://alexch.github.com Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch | http://alexch.tumblr.com --001636c927fcc85db904af342d02--