Class: Xpect::Matchers
- Inherits:
-
Object
- Object
- Xpect::Matchers
- Defined in:
- lib/xpect/matchers.rb
Class Method Summary collapse
Class Method Details
.anything ⇒ Object
3 4 5 |
# File 'lib/xpect/matchers.rb', line 3 def self.anything lambda {|_| true } end |
.falsy ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 ⇒ Object
7 8 9 10 11 12 13 14 15 |
# 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) ⇒ Object
45 46 47 |
# File 'lib/xpect/matchers.rb', line 45 def self.raise_error(msg) raise FailedSpec, msg end |
.truthy ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 |