Class: Merb::Test::Rspec::ControllerMatchers::BeError

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-core/test/matchers/controller_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BeError

Returns a new instance of BeError.



35
36
37
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 35

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject



45
46
47
48
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 45

def failure_message
  "expected #{@target} to be a #{@expected} error, but it was " << 
    @target.request.exceptions.first.inspect
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 39

def matches?(target)
  @target = target
  @target.request.exceptions &&
    @target.request.exceptions.first.is_a?(@expected)
end

#negative_failure_messageObject



50
51
52
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 50

def negative_failure_message
  "expected #{@target} not to be a #{@expected} error, but it was"
end