mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Raise UnexpectedMessageError
This commit is contained in:
parent
18b3879dce
commit
925af7908b
2 changed files with 6 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
require "./generic_method_call"
|
||||
require "./generic_method_stub"
|
||||
require "./unexpected_message_error"
|
||||
|
||||
module Spectator::Mocks
|
||||
abstract class Double
|
||||
|
@ -61,7 +62,7 @@ module Spectator::Mocks
|
|||
{% if body && !body.is_a?(Nop) %}
|
||||
{{body.body}}
|
||||
{% else %}
|
||||
raise "Stubbed method called without being allowed"
|
||||
raise ::Spectator::Mocks::UnexpectedMessageError.new("#{self} received unexpected message {{name}}")
|
||||
# This code shouldn't be reached, but makes the compiler happy to have a matching return type.
|
||||
{% if definition.is_a?(TypeDeclaration) %}
|
||||
%x = uninitialized {{definition.type}}
|
||||
|
|
4
src/spectator/mocks/unexpected_message_error.cr
Normal file
4
src/spectator/mocks/unexpected_message_error.cr
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Spectator::Mocks
|
||||
class UnexpectedMessageError < Exception
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue