Class: Caricature::RSpecMatchers::HaveRaised

Inherits:
Object
  • Object
show all
Defined in:
lib/caricature/rspec/integration.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveRaised

Returns a new instance of HaveRaised.



65
66
67
68
# File 'lib/caricature/rspec/integration.rb', line 65

def initialize(expected)
  @expected = expected
  @block_args, @error, @args = nil, "", [:any]
end

Instance Method Details

#allow_any_argumentsObject

allow any arguments ignore the argument constraint



99
100
101
102
# File 'lib/caricature/rspec/integration.rb', line 99

def allow_any_arguments
  @args = :any
  self
end

#failure_message_for_shouldObject



81
82
83
# File 'lib/caricature/rspec/integration.rb', line 81

def failure_message_for_should
  "expected #{@target.inspect} to have received #{@expected}" + @error
end

#failure_message_for_should_notObject



85
86
87
# File 'lib/caricature/rspec/integration.rb', line 85

def failure_message_for_should_not
  "expected #{@target.inspect} not to have received #{@expected}" + @error
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
78
79
# File 'lib/caricature/rspec/integration.rb', line 70

def matches?(target)
  @target = target

  veri = @target.did_raise_event?(@expected).with(*@args)
  result = veri.successful?

  @error = "\n#{veri.error}" unless result

  result
end

#with(*args) ⇒ Object

constrain this verification to the provided arguments



90
91
92
93
94
95
96
# File 'lib/caricature/rspec/integration.rb', line 90

def with(*args)
  ags = *args
  @args = args
  @args = [:any] if (args.first.is_a?(Symbol) and args.first == :any) || ags.nil?
  # @callback = b if b
  self
end