Module: AE::Detest

Included in:
World
Defined in:
lib/ae/detest.rb

Overview

Given that x is “tom” then we can assert it is using an asseretion pipe.

x = "tom"

T x == "tom"

We can assert the opposite using F.

F x == "tom"

These can be used at any point of return.

T case x
   when 'tom' then true
   else false
   end

Instance Method Summary collapse

Instance Method Details

#E(&b) ⇒ Object

Expect and error.

E { raise }

Unless #T, #F and #N, the #E method only supports block notation.



53
54
55
# File 'lib/ae/detest.rb', line 53

def E(&b)
  expect(Exception, &b)
end

#F(x = nil, &b) ⇒ Object

Test for not.

F 1 == 2


36
37
38
# File 'lib/ae/detest.rb', line 36

def F(x=nil, &b)
  Assertion.test(!(x || b.call), :backtrace=>caller)
end

#N(x = nil, &b) ⇒ Object

Test for nil?.

N nil


44
45
46
# File 'lib/ae/detest.rb', line 44

def N(x=nil,&b)
  Assertion.test(nil == (x || b.call), :backtrace=>caller)
end

#T(x = nil, &b) ⇒ Object

Test for true.

T 1 == 1


28
29
30
# File 'lib/ae/detest.rb', line 28

def T(x=nil, &b)
  Assertion.test(x || b.call, :backtrace=>caller)
end