class Xpect::Matchers
Public Class Methods
anything()
click to toggle source
# File lib/xpect/matchers.rb, line 3 def self.anything lambda {|_| true } end
falsy()
click to toggle source
# File lib/xpect/matchers.rb, line 17 def self.falsy lambda do |val| if val.is_a?(Integer) || val.is_a?(Float) raise_error("'#{ val }' is not falsy.") end if val.nil? || val.empty? return true end raise_error("'#{ val }' is not falsy.") end end
nil()
click to toggle source
# File lib/xpect/matchers.rb, line 7 def self.nil lambda do |val| unless val.nil? raise_error("'#{ val }' is not nil.") end true end end
raise_error(msg)
click to toggle source
# File lib/xpect/matchers.rb, line 45 def self.raise_error(msg) raise FailedSpec, msg end
truthy()
click to toggle source
# File lib/xpect/matchers.rb, line 31 def self.truthy lambda do |val| if val.is_a?(Integer) || val.is_a?(Float) return true end if val.nil? || val.empty? raise_error("'#{ val }' is not truthy.") end true end end