class Crabfarm::Assertion::Wrapper
Public Class Methods
new(_value, _context=nil)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 10 def initialize(_value, _context=nil) @value = if _value.respond_to? :text _value.text else _value end @context = _context end
Public Instance Methods
is_boolean(_options={}, &_block)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 58 def is_boolean(_options={}, &_block) perform_assertion(_options) { @value = parse_boolean @value, _options, &_block } end
Also aliased as: is_b
is_float(_options={}, &_block)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 28 def is_float(_options={}, &_block) perform_assertion(_options) { @value = parse_float @value, _options validate_number @value, _options validate_general @value, _options, &_block } end
Also aliased as: is_f
is_integer(_options={}, &_block)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 18 def is_integer(_options={}, &_block) perform_assertion(_options) { @value = parse_integer @value, _options validate_number @value, _options validate_general @value, _options, &_block } end
Also aliased as: is_i
is_string(_options={}, &_block)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 48 def is_string(_options={}, &_block) perform_assertion(_options) { @value = parse_phrase @value, _options validate_string @value, _options validate_general @value, _options, &_block } end
Also aliased as: is_s
is_word(_options={}, &_block)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 38 def is_word(_options={}, &_block) perform_assertion(_options) { @value = parse_phrase @value, _options validate_word @value, _options validate_general @value, _options, &_block } end
Also aliased as: is_w
matches(_rgx, _options={})
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 66 def matches(_rgx, _options={}) perform_assertion(_options) { match = _rgx.match @value fail_with "#{@value} does not match #{_rgx.to_s}" if match.nil? match } end
method_missing(_method, *_args)
click to toggle source
Calls superclass method
# File lib/crabfarm/assertion/wrapper.rb, line 74 def method_missing(_method, *_args) if @value.respond_to? :method @value = @value.send(*_args) else super end end
respond_to?(*args)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 80 def respond_to?(*args) @value.respond_to?(*args) end
Private Instance Methods
fail_with(_message)
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 96 def fail_with(_message) raise AssertionError.new _message end
perform_assertion(_options) { || ... }
click to toggle source
# File lib/crabfarm/assertion/wrapper.rb, line 86 def perform_assertion(_options) begin yield @value rescue AssertionError # => exc # for now just raise, in the future event could be hooked here... raise end end