Sha256: 652e06b724a66790bc7f28978fd70a80e7af99f045ec3a641779a4666c4ad7b0
Contents?: true
Size: 951 Bytes
Versions: 3
Compression:
Stored size: 951 Bytes
Contents
module Riot # Asserts the result contains the expected element # # asserts("a string") { "world" }.includes('o') # asserts("an array") { [1,2,3] }.includes(2) # asserts("a range") { (1..15) }.includes(10) # # You can also assert that the result does not contain an element: # # denies("a string") { "world" }.includes('f') # denies("an array") { [1,2,3,4,5] }.includes(0) # denies("a range") { (1..15) }.includes(16) class IncludesMacro < AssertionMacro register :includes def evaluate(actual, expected) if actual.include?(expected) pass new_message.includes(expected) else fail expected_message(actual).to_include(expected) end end def devaluate(actual, expected) if actual.include?(expected) fail expected_message(actual).to_not_include(expected) else pass new_message.does_not_include(expected) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riot-0.12.1 | lib/riot/assertion_macros/includes.rb |
riot-0.12.0 | lib/riot/assertion_macros/includes.rb |
riot-0.12.0.pre | lib/riot/assertion_macros/includes.rb |