Class: Caricature::RSpecMatchers::HaveReceived
- 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) ⇒ HaveReceived
constructor
A new instance of HaveReceived.
- #matches?(target) ⇒ Boolean
-
#with(*args) ⇒ Object
constrain this verification to the provided arguments.
- #with_block_args(*args) ⇒ Object
Constructor Details
#initialize(expected) ⇒ HaveReceived
Returns a new instance of HaveReceived.
23 24 25 26 |
# File 'lib/caricature/rspec/integration.rb', line 23 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
63 64 65 66 |
# File 'lib/caricature/rspec/integration.rb', line 63 def allow_any_arguments @args = :any self end |
#failure_message_for_should ⇒ Object
40 41 42 |
# File 'lib/caricature/rspec/integration.rb', line 40 def "expected #{@target.inspect} to have received #{@expected}" + @error end |
#failure_message_for_should_not ⇒ Object
44 45 46 |
# File 'lib/caricature/rspec/integration.rb', line 44 def "expected #{@target.inspect} not to have received #{@expected}" + @error end |
#matches?(target) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/caricature/rspec/integration.rb', line 28 def matches?(target) @target = target veri = @target.did_receive?(@expected).with(*@args) veri.with_block_args(*@block_args) if @block_args result = veri.successful? @error = "\n#{veri.error}" unless result result end |
#with(*args) ⇒ Object
constrain this verification to the provided arguments
49 50 51 52 53 54 55 |
# File 'lib/caricature/rspec/integration.rb', line 49 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 |
#with_block_args(*args) ⇒ Object
57 58 59 60 |
# File 'lib/caricature/rspec/integration.rb', line 57 def with_block_args(*args) @block_args = args self end |