Sha256: b897c559d2d5239f5e86e55b1409c1a2e10b67471598fa1523465262d557eef5

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

module Riot
  # Asserts the result of the test is a non-truthy value. Read the following assertions in the way Borat
  # learned about humor:
  #
  #   asserts("you are funny") { false }.not!
  #   should("be funny") { nil }.not!
  #
  # Thusly, Borat would say "You are funny ... not!" The above two assertions would pass because the values
  # are non-truthy.
  #
  # You can also apply not to the negative assertion (denies), but I'm not sure how much sense it would make.
  # It would be kind of like a double negative:
  #
  #   denies("you are funny") { true }.not!
  class NotMacro < AssertionMacro
    register :not!

    def evaluate(actual)
      actual ? fail("expected to exist ... not!") : pass("does exist ... not!")
    end
    
    def devaluate(actual)
      actual ? pass("does not exist ... not!") : fail("expected to not exist ... not!")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riot-0.12.1 lib/riot/assertion_macros/not_borat.rb
riot-0.12.0 lib/riot/assertion_macros/not_borat.rb
riot-0.12.0.pre lib/riot/assertion_macros/not_borat.rb