Class: Spec::Expectations::Should::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/expectations/should/base.rb

Direct Known Subclasses

Change, Not, Should

Instance Method Summary collapse

Instance Method Details

#==(expected) ⇒ Object

and =~ will stay after the new syntax



7
8
9
# File 'lib/spec/expectations/should/base.rb', line 7

def ==(expected)
  __delegate_method_missing_to_target "==", "==", expected
end

#=~(expected) ⇒ Object



11
12
13
# File 'lib/spec/expectations/should/base.rb', line 11

def =~(expected)
  __delegate_method_missing_to_target "=~", "=~", expected
end

#default_message(expectation, expected = nil) ⇒ Object



35
36
37
38
# File 'lib/spec/expectations/should/base.rb', line 35

def default_message(expectation, expected=nil)
  return "expected #{expected.inspect}, got #{@target.inspect} (using #{expectation})" if expectation == '=='
  "expected #{expectation} #{expected.inspect}, got #{@target.inspect}" unless expectation == '=='
end

#fail_with_message(message, expected = nil, target = nil) ⇒ Object



40
41
42
# File 'lib/spec/expectations/should/base.rb', line 40

def fail_with_message(message, expected=nil, target=nil)
  Spec::Expectations.fail_with(message, expected, target)
end

#find_supported_sym(original_sym) ⇒ Object



44
45
46
47
48
# File 'lib/spec/expectations/should/base.rb', line 44

def find_supported_sym(original_sym)
  ["#{original_sym}?", "#{original_sym}s?"].each do |alternate_sym|
    return alternate_sym.to_s if @target.respond_to?(alternate_sym.to_s)
  end
end