Sha256: 81a0d636f02468b0d68908575df9c20b6708c03f399afc56e800364f7fedb337

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

module Riot
  # In the positive case, asserts that the result of the test equals the expected value. Using the +==+ 
  # operator to assert equality.
  #
  #   asserts("test") { "foo" }.equals("foo")
  #   should("test") { "foo" }.equals("foo")
  #   asserts("test") { "foo" }.equals { "foo" }
  #
  # In the negative case, asserts that the result of the test *does not* equal the expected value. Using the
  # +==+ operator.
  #
  #   denies("test") { "foo" }.equals("bar")
  #   denies("test") { "foo" }.equals { "bar" }
  class EqualsMacro < AssertionMacro
    register :equals

    def evaluate(actual, expected)
      if expected == actual
        pass new_message.is_equal_to(expected)
      else
        fail expected_message(expected).not(actual)
      end
    end

    def devaluate(actual, expected)
      if expected != actual
        pass new_message.is_equal_to(expected).when_it_is(actual)
      else
        fail new_message.did_not_expect(actual)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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