Class: Lebowski::RSpec::Operators::That

Inherits:
Operator
  • Object
show all
Defined in:
lib/lebowski/rspec/operators/that.rb

Instance Method Summary collapse

Constructor Details

#initialize(sym, *args) ⇒ That

Returns a new instance of That.



12
13
14
15
# File 'lib/lebowski/rspec/operators/that.rb', line 12

def initialize(sym, *args)
  @sym = sym
  @args = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



54
55
56
# File 'lib/lebowski/rspec/operators/that.rb', line 54

def method_missing(sym, *args, &block)
  return self
end

Instance Method Details

#evaluate(value) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lebowski/rspec/operators/that.rb', line 17

def evaluate(value)
  case operator
  when :not_empty
    return not_empty? value
  when :empty
    return empty? value
  when :between
    return between? value
  when :at_most
    return at_most? value
  when :at_least
    return at_least? value
  when :greater_than
    return greater_than? value
  when :less_than
    return less_than? value
  when :contains
    return contains? value
  when :matches
    return matches? value
  when :equals
    return equals? value
  when :equal_to
    return equals? value
  else
    raise ArgumentError "Invalid that operator: #{operator}"
  end
end

#operatorObject



46
47
48
49
50
51
52
# File 'lib/lebowski/rspec/operators/that.rb', line 46

def operator()
  ["that_is_", "that_"].each do |prefix|
    if @sym =~ /^#{prefix}/
      return @sym.to_s.sub(prefix, "").to_sym
    end
  end
end