Class: RSpec::Given::Failure

Inherits:
BasicObject
Defined in:
lib/rspec/given/failure.rb

Overview

Failure objects will raise the given exception whenever you try to send it any message.

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ Failure

Returns a new instance of Failure.



9
10
11
# File 'lib/rspec/given/failure.rb', line 9

def initialize(exception)
  @exception = exception
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



33
34
35
# File 'lib/rspec/given/failure.rb', line 33

def method_missing(sym, *args, &block)
  die
end

Instance Method Details

#!=(other) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rspec/given/failure.rb', line 25

def !=(other)
  if failed_matcher?(other)
    ! other.matches?(self)
  else
    die
  end
end

#==(other) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rspec/given/failure.rb', line 17

def ==(other)
  if failed_matcher?(other)
    other.matches?(self)
  else
    die
  end
end

#is_a?(klass) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rspec/given/failure.rb', line 13

def is_a?(klass)
  klass == Failure
end

#respond_to?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rspec/given/failure.rb', line 37

def respond_to?(method_name)
  method_name == :call
end