Concept "Message Expectations"

From SMW CindyKate - Main
Component 321531
Jump to: navigation, search

Content


= method-level applied to object-level concepts

my_double.should_receive(:some_method).and_return("something") # raises an error if never called

Counts

my_double.should_receive(:some_method).exactly.once

Negative expectation

Expected arguments

Argument Matchers

  • instance_of
  • anything
  • any_args
  • no_args
  • hash_including
  • hash_not_including
  • Regexes

Custom Argument Matchers

Return consecutive values

Throwing/raising an exception

Ordering

Message expectations can override stubs