Sha256: 70806a34e69024121462f7359bae96400388cac4324e217efe6c77d2eb7fceee
Contents?: true
Size: 899 Bytes
Versions: 3
Compression:
Stored size: 899 Bytes
Contents
module Riot # Asserts that the result of the test is a non-nil value. This is useful in the case where you don't want # to translate the result of the test into a boolean value # # asserts("test") { "foo" }.exists # should("test") { 123 }.exists # asserts("test") { "" }.exists # asserts("test") { nil }.exists # This would fail # # You can also test for non-existince (being nil), but if you would better if you used the +nil+ macro: # # denies("test") { nil }.exists # would pass # asserts("test") { nil }.nil # same thing # # denies("test") { "foo" }.exists # would fail class ExistsMacro < AssertionMacro register :exists def evaluate(actual) actual.nil? ? fail("expected a non-nil value") : pass("is not nil") end def devaluate(actual) actual.nil? ? pass("is nil") : fail("expected a nil value") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riot-0.12.1 | lib/riot/assertion_macros/exists.rb |
riot-0.12.0 | lib/riot/assertion_macros/exists.rb |
riot-0.12.0.pre | lib/riot/assertion_macros/exists.rb |