Class: Moqueue::Matchers::HasReceived

Inherits:
Object
  • Object
show all
Defined in:
lib/moqueue/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_msg) ⇒ HasReceived

Returns a new instance of HasReceived.



6
7
8
# File 'lib/moqueue/matchers.rb', line 6

def initialize(expected_msg)
  @expected_msg = expected_msg
end

Instance Method Details

#failure_message_for_shouldObject



21
22
23
# File 'lib/moqueue/matchers.rb', line 21

def failure_message_for_should
  "expected #{@queue.inspect} to have received message ``#{@expected_msg}''"
end

#failure_message_for_should_notObject



25
26
27
# File 'lib/moqueue/matchers.rb', line 25

def failure_message_for_should_not
  "expected #{@queue.inspect} to not have received message ``#{@expected_msg}''"
end

#matches?(queue) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
# File 'lib/moqueue/matchers.rb', line 10

def matches?(queue)
  if queue.respond_to?(:received_message?)
    @queue = queue
    @queue.received_message?(@expected_msg)
  else
    raise NoMethodError, 
    "Grrr. you can't use ``should have_received_message'' on #{queue.inspect} " +
    "because it doesn't respond_to :received_message?"
  end
end