Module: ActiveMessaging::TestHelper

Defined in:
lib/activemessaging/test_helper.rb

Instance Method Summary collapse

Instance Method Details

#assert_has_messages(destination) ⇒ Object



108
109
110
111
112
113
114
115
116
117
# File 'lib/activemessaging/test_helper.rb', line 108

def assert_has_messages destination
  destination_name = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  No messages for \#{destination_name}.\n  All messages:\n  \#{ActiveMessaging::Gateway.connection('default').all_messages.inspect}\n  EOF\n  destination = ActiveMessaging::Gateway.connection('default').find_destination destination_name\n  assert !destination.nil? && !destination.messages.empty?, error_message\nend\n"

#assert_message(destination, body) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/activemessaging/test_helper.rb', line 58

def assert_message destination, body
  destination = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  Message for '\#{destination}' with '\#{body}' is not present.\n  Messages:\n  \#{ActiveMessaging::Gateway.connection('default').all_messages.inspect}\n  EOF\n  assert ActiveMessaging::Gateway.connection.find_message(destination, body), error_message\nend\n"

#assert_no_message_with(destination, body) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/activemessaging/test_helper.rb', line 68

def assert_no_message_with destination, body
  destination = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  Message for '\#{destination}' with '\#{body}' is present.\n  Messages:\n  \#{ActiveMessaging::Gateway.connection('default').all_messages.inspect}\n  EOF\n  assert_nil ActiveMessaging::Gateway.connection('default').find_message(destination, body), error_message\nend\n"

#assert_no_messages(destination) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/activemessaging/test_helper.rb', line 78

def assert_no_messages destination
  destination = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  Expected no messages.\n  Messages:\n  \#{ActiveMessaging::Gateway.connection('default').all_messages.inspect}\n  EOF\n  assert_equal [], ActiveMessaging::Gateway.connection('default').all_messages, error_message\nend\n"

#assert_not_subscribed(destination) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/activemessaging/test_helper.rb', line 98

def assert_not_subscribed destination
  destination = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  Subscribed to \#{destination}.\n  Subscriptions:\n  \#{ActiveMessaging::Gateway.connection('default').subscriptions.inspect}\n  EOF\n  assert_nil ActiveMessaging::Gateway.connection('default').find_subscription(destination), error_message\nend\n"

#assert_subscribed(destination) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/activemessaging/test_helper.rb', line 88

def assert_subscribed destination
  destination = ActiveMessaging::Gateway.find_destination(destination).value
  error_message = "  Not subscribed to \#{destination}.\n  Subscriptions:\n  \#{ActiveMessaging::Gateway.connection('default').subscriptions.inspect}\n  EOF\n  assert ActiveMessaging::Gateway.connection('default').find_subscription(destination), error_message\nend\n"

#mock_publish(destination, body, publisher = nil, headers = {}) ⇒ Object



54
55
56
# File 'lib/activemessaging/test_helper.rb', line 54

def mock_publish destination, body, publisher=nil, headers={}
  ActiveMessaging::Gateway.publish destination, body, publisher, headers
end