Skip to content

Commit

Permalink
chore: fix integration test
Browse files Browse the repository at this point in the history
The test previously did nothing.
  • Loading branch information
jgraichen committed Aug 16, 2023
1 parent 0c917d6 commit 5b3fd8b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
7 changes: 6 additions & 1 deletion spec/integration/dummy/app/consumers/test_consumer.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# frozen_string_literal: true

class TestConsumer < ApplicationConsumer
class << self
attr_accessor :queue
end

def index
data = {fuubar: 'abc'}

publish data, to: 'local.test.another_action'
end

def another_action
puts payload.inspect.to_s
self.class.queue ||= []
self.class.queue << payload
end
end
2 changes: 2 additions & 0 deletions spec/integration/dummy/config/rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ common: &common

test:
<<: *common
pool_class: Msgr::TestPool
raise_exceptions: true

development:
<<: *common
Expand Down
6 changes: 6 additions & 0 deletions spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@
config.before do
Msgr.logger = false
end

config.after do
# Flush the consumer queue
Msgr.client.stop delete: true
Msgr::TestPool.reset
end
end
12 changes: 10 additions & 2 deletions spec/integration/test_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

require 'spec_helper'

describe TestController, type: :request do
describe TestController, type: :controller do
before do
Msgr.client.start
end

it 'sends messages on :index' do
get '/'
get :index

Msgr::TestPool.run(count: 2)

expect(TestConsumer.queue).to eq [{fuubar: 'abc'}]
end
end

0 comments on commit 5b3fd8b

Please sign in to comment.