20 Apr 2013, 14:26

Louis Rhys (22 posts)

In Iteration G1, one of the unit test line says @assert_equal flash[:notice], ‘Your cart is empty’@

What if I want to make a less strict assertion, like I’m ok as long as the string contains “cart” and “empty”? Looking at “this list”:http://ruby-doc.org/stdlib-1.8.7/libdoc/test/unit/rdoc/Test/Unit/Assertions.html , can assert_match be used for this? What will the pattern look like?

20 Apr 2013, 17:35

Sam Ruby (584 posts)

assert_match /cart/, flash[:notice], 'not a cart'
assert_match /empty/, flash[:notice], 'not empty'
  You must be logged in to comment