Class: Speccify::OperatorMatcherProxy
- Inherits:
-
Object
- Object
- Speccify::OperatorMatcherProxy
- Defined in:
- lib/speccify.rb
Overview
Functions
Class Method Summary collapse
Class Method Details
.create(given, loc, type = true) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/speccify.rb', line 114 def self.create given, loc, type = true body = lambda do |klass| define_method(:initialize) do |given| @given = given end ['==', '===', '=~', '>', '>=', '<', '<='].each do |operator| define_method(operator) do |actual| print_given = (@given == nil) ? "nil" : @given print_actual = (type ? "" : "not ") + (actual.nil? ? "nil" : actual.to_s) msg = Speccify::Functions::(print_actual, print_given, operator, loc) $current_spec.assert(type == @given.send(operator,actual), msg) end end end return Class.new(&body).new(given) end |