Skip to content

Instantly share code, notes, and snippets.

@anewusername1
Created August 17, 2011 22:02
Show Gist options
  • Save anewusername1/1152758 to your computer and use it in GitHub Desktop.
Save anewusername1/1152758 to your computer and use it in GitHub Desktop.
subscriber code example
EM.schedule do
user_subscription = Subscriptions::User.new
Ragnar.exchange(:topic, 'events') do |x|
x.queue_prefix = :service_name
x.subscribe('user.delete', &user_subscription.method(:user_delete))
x.subscribe('user.login', &user_subscription.method(:user_login))
end
end
module Subscriptions
class User
def user_delete(headers, payload)
begin
# do something here
rescue
# handle the errors
end
end
def user_login(headers, payload)
begin
# do something here
rescue
#handle the errors
end
end
end
end
require 'spec_helper'
describe Subscriptions::User do
describe '#user_delete' do
context 'no errors' do
it 'checks that something happened' do
# spec here
end
end
context 'errors' do
it 'checks that the right error was raised' do
# spec here
end
end
end
describe '#user_login' do
context 'no errors' do
it 'checks that something happened' do
# spec here
end
end
context 'errors' do
it 'checks that the right error was raised' do
# spec here
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment