Sha256: b2df2f6d8e1e5ebc9f014b13ef762b8683fb4dc1c2c03d4bb4f18e0ffc611225

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module Riot
  # In the postive case, asserts the result of the test is empty.
  #
  #   asserts("a string") { "" }.empty
  #   asserts("an array") { [] }.empty
  #   asserts("a hash") { Hash.new }.empty
  #
  # In the negative case, asserts the result of the test is not empty.
  #
  #   denies("a string") { "foo" }.empty
  #   denies("an array") { [1] }.empty
  #   denies("a hash") { {:foo => "bar" } }.empty
  class EmptyMacro < AssertionMacro
    register :empty

    def evaluate(actual)
      actual.empty? ? pass(new_message.is_empty) : fail(expected_message(actual).to_be_empty)
    end

    def devaluate(actual)
      actual.empty? ? fail(expected_message(actual).to_not_be_empty) : pass(new_message.is_empty)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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