Class: Caricature::RSpecMatchers::HaveRaised
- Defined in:
- lib/caricature/rspec/integration.rb
Instance Method Summary collapse
-
#allow_any_arguments ⇒ Object
allow any arguments ignore the argument constraint.
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected) ⇒ HaveRaised
constructor
A new instance of HaveRaised.
- #matches?(target) ⇒ Boolean
-
#with(*args) ⇒ Object
constrain this verification to the provided arguments.
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_arguments ⇒ Object
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_should ⇒ Object
81 82 83 |
# File 'lib/caricature/rspec/integration.rb', line 81 def "expected #{@target.inspect} to have received #{@expected}" + @error end |
#failure_message_for_should_not ⇒ Object
85 86 87 |
# File 'lib/caricature/rspec/integration.rb', line 85 def "expected #{@target.inspect} not to have received #{@expected}" + @error end |
#matches?(target) ⇒ 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 |