msgr 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -1
- data/.travis.yml +5 -3
- data/Gemfile +27 -2
- data/Guardfile +14 -0
- data/README.md +56 -5
- data/Rakefile +30 -4
- data/lib/msgr/binding.rb +34 -7
- data/lib/msgr/client.rb +54 -24
- data/lib/msgr/connection.rb +64 -17
- data/lib/msgr/consumer.rb +28 -0
- data/lib/msgr/dispatcher.rb +12 -5
- data/lib/msgr/logging.rb +1 -1
- data/lib/msgr/message/acknowledge.rb +30 -0
- data/lib/msgr/message.rb +10 -3
- data/lib/msgr/pool.rb +31 -31
- data/lib/msgr/railtie.rb +51 -0
- data/lib/msgr/route.rb +19 -6
- data/lib/msgr/routes.rb +34 -2
- data/lib/msgr/version.rb +1 -1
- data/lib/msgr.rb +15 -7
- data/msgr.gemspec +2 -5
- data/scripts/simple_test.rb +18 -94
- data/spec/fixtures/msgr-routes-test-1.rb +2 -0
- data/spec/integration/dummy/README.rdoc +28 -0
- data/spec/integration/dummy/Rakefile +6 -0
- data/spec/integration/dummy/app/assets/images/.keep +0 -0
- data/spec/integration/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/integration/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/integration/dummy/app/consumers/application_consumer.rb +3 -0
- data/spec/integration/dummy/app/consumers/test_consumer.rb +12 -0
- data/spec/integration/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/integration/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/integration/dummy/app/controllers/test_controller.rb +10 -0
- data/spec/integration/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/integration/dummy/app/mailers/.keep +0 -0
- data/spec/integration/dummy/app/models/.keep +0 -0
- data/spec/integration/dummy/app/models/concerns/.keep +0 -0
- data/spec/integration/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/integration/dummy/bin/bundle +3 -0
- data/spec/integration/dummy/bin/rails +4 -0
- data/spec/integration/dummy/bin/rake +4 -0
- data/spec/integration/dummy/config/application.rb +24 -0
- data/spec/integration/dummy/config/boot.rb +5 -0
- data/spec/integration/dummy/config/database.yml +25 -0
- data/spec/integration/dummy/config/environment.rb +5 -0
- data/spec/integration/dummy/config/environments/development.rb +29 -0
- data/spec/integration/dummy/config/environments/production.rb +80 -0
- data/spec/integration/dummy/config/environments/test.rb +36 -0
- data/spec/integration/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/integration/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/integration/dummy/config/initializers/inflections.rb +16 -0
- data/spec/integration/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/integration/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/integration/dummy/config/initializers/session_store.rb +3 -0
- data/spec/integration/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/integration/dummy/config/locales/en.yml +23 -0
- data/spec/integration/dummy/config/msgr.rb +3 -0
- data/spec/integration/dummy/config/rabbitmq.yml +11 -0
- data/spec/integration/dummy/config/routes.rb +58 -0
- data/spec/integration/dummy/config.ru +4 -0
- data/spec/integration/dummy/db/test.sqlite3 +0 -0
- data/spec/integration/dummy/lib/assets/.keep +0 -0
- data/spec/integration/dummy/log/.keep +0 -0
- data/spec/integration/dummy/public/404.html +58 -0
- data/spec/integration/dummy/public/422.html +58 -0
- data/spec/integration/dummy/public/500.html +57 -0
- data/spec/integration/dummy/public/favicon.ico +0 -0
- data/spec/integration/msgr/railtie_spec.rb +12 -0
- data/spec/integration/msgr_spec.rb +12 -0
- data/spec/integration/spec_helper.rb +48 -0
- data/spec/msgr/msgr/client_spec.rb +50 -0
- data/spec/msgr/msgr/connection_spec.rb +51 -0
- data/spec/msgr/{consumer_spec.rb → msgr/consumer_spec.rb} +0 -0
- data/spec/msgr/msgr/pool_spec.rb +68 -0
- data/spec/msgr/{route_spec.rb → msgr/route_spec.rb} +0 -0
- data/spec/msgr/msgr/routes_spec.rb +113 -0
- data/spec/msgr/msgr_spec.rb +36 -0
- data/spec/{spec_helper.rb → msgr/spec_helper.rb} +15 -0
- data/spec/msgr/support/.keep +0 -0
- data/spec/support/setup.rb +27 -0
- metadata +126 -59
- data/spec/msgr/client_spec.rb +0 -5
- data/spec/msgr/routes_spec.rb +0 -59
- data/spec/msgr_spec.rb +0 -5
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Msgr::Connection do
|
4
|
+
|
5
|
+
describe '#rebind' do
|
6
|
+
let(:conn) { double }
|
7
|
+
let(:routes) { Msgr::Routes.new }
|
8
|
+
let(:connection) { Msgr::Connection.new conn, routes, dispatcher }
|
9
|
+
|
10
|
+
context 'with URI' do
|
11
|
+
it 'should pass URI options to bunny (I)' do
|
12
|
+
expect(Bunny).to receive(:new)
|
13
|
+
.with(pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/')
|
14
|
+
|
15
|
+
Msgr::Client.new uri: 'amqp://guest:guest@localhost/'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should pass URI options to bunny (II)' do
|
19
|
+
expect(Bunny).to receive(:new)
|
20
|
+
.with(pass: 'msgr', user: 'abc', ssl: true, host: 'bogus.example.org', vhost: '/rabbit')
|
21
|
+
|
22
|
+
Msgr::Client.new uri: 'amqps://abc:msgr@bogus.example.org/rabbit'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with options' do
|
27
|
+
it 'should pass options to bunny' do
|
28
|
+
expect(Bunny).to receive(:new)
|
29
|
+
.with(pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/')
|
30
|
+
|
31
|
+
Msgr::Client.new pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with URI and options' do
|
36
|
+
it 'should pass merged options to bunny' do
|
37
|
+
expect(Bunny).to receive(:new)
|
38
|
+
.with(pass: 'msgr', user: 'abc', ssl: false, host: 'localhost', vhost: '/joghurt')
|
39
|
+
|
40
|
+
Msgr::Client.new uri: 'ampq://abc@localhost', pass: 'msgr', vhost: '/joghurt'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should pass prefer hash option' do
|
44
|
+
expect(Bunny).to receive(:new)
|
45
|
+
.with(ssl: true, host: 'a.example.org', vhost: '/', user: 'guest')
|
46
|
+
|
47
|
+
Msgr::Client.new uri: 'ampq://localhost', ssl: true, host: 'a.example.org'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
$shutdown_test_graceful_down = false
|
4
|
+
|
5
|
+
class Runner
|
6
|
+
def call(*_) end
|
7
|
+
|
8
|
+
def shutdown_test
|
9
|
+
sleep 2
|
10
|
+
$shutdown_test_graceful_down = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Msgr::Pool do
|
15
|
+
let(:pool) { Msgr::Pool.new Runner }
|
16
|
+
|
17
|
+
describe '#initialize' do
|
18
|
+
let(:opts) { {} }
|
19
|
+
let(:pool) { Msgr::Pool.new Runner, opts }
|
20
|
+
|
21
|
+
context 'pool size' do
|
22
|
+
let(:opts) { {size: 4} }
|
23
|
+
before { pool }
|
24
|
+
|
25
|
+
it 'should define number of worker actors' do
|
26
|
+
expect(pool.size).to eq 4
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#start' do
|
32
|
+
let!(:pool) { Msgr::Pool.new Runner, size: 4 }
|
33
|
+
|
34
|
+
it 'should start worker actors' do
|
35
|
+
expect { pool.start }.to change { Celluloid::Actor.all.size }.by(4)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#size' do
|
40
|
+
it 'should default to number of available cores' do
|
41
|
+
expect(pool.size).to eq Celluloid.cores
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#dispatch' do
|
46
|
+
let!(:pool) { Msgr::Pool.new Runner, size: 4 }
|
47
|
+
before { pool.start }
|
48
|
+
|
49
|
+
it 'should dispatch message to runner' do
|
50
|
+
expect_any_instance_of(Runner).to receive(:call).within(10).seconds.once
|
51
|
+
pool.dispatch 5, 3.2, 'hello'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#shutdown' do
|
56
|
+
let!(:pool) { Msgr::Pool.new Runner, size: 1 }
|
57
|
+
before do
|
58
|
+
pool.start
|
59
|
+
$shutdown_test_graceful_down = false
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should do a graceful shutdown of all worker' do
|
63
|
+
pool.dispatch :shutdown_test
|
64
|
+
pool.shutdown
|
65
|
+
expect($shutdown_test_graceful_down).to be_false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
File without changes
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Msgr::Routes do
|
4
|
+
let(:routes) { Msgr::Routes.new }
|
5
|
+
|
6
|
+
describe '#configure' do
|
7
|
+
let(:block) { Proc.new{} }
|
8
|
+
|
9
|
+
it 'should evaluate given block within instance context' do
|
10
|
+
expect(routes).to receive(:instance_eval).with { |p| p == block }
|
11
|
+
|
12
|
+
routes.configure &block
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should allow to call instance method in gven block' do
|
16
|
+
expect(routes).to receive(:test_instance_method).with(:abc)
|
17
|
+
|
18
|
+
routes.configure do
|
19
|
+
test_instance_method :abc
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#each' do
|
25
|
+
before do
|
26
|
+
routes.configure do
|
27
|
+
route 'abc.#', to: 'test#index'
|
28
|
+
route 'edf.#', to: 'test#action'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:each) { routes.each }
|
33
|
+
|
34
|
+
it 'should iterate over configured routes' do
|
35
|
+
expect(each).to have(2).items
|
36
|
+
|
37
|
+
expect(each.map(&:keys)).to eq [%w(abc.#), %w(edf.#)]
|
38
|
+
expect(each.map(&:consumer)).to eq %w(TestConsumer TestConsumer)
|
39
|
+
expect(each.map(&:action)).to eq %w(index action)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#route' do
|
44
|
+
let(:subject) { -> { routes.route 'routing.key', to: 'test2#index2' } }
|
45
|
+
let(:last_route) { routes.routes.last }
|
46
|
+
|
47
|
+
it 'should add a new route' do
|
48
|
+
expect { subject.call }.to change{ routes.routes.size }.from(0).to(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should add given route' do
|
52
|
+
subject.call
|
53
|
+
|
54
|
+
expect(last_route.keys).to eq %w(routing.key)
|
55
|
+
expect(last_route.consumer).to eq 'Test2Consumer'
|
56
|
+
expect(last_route.action).to eq 'index2'
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with same target' do
|
60
|
+
let(:subject) do
|
61
|
+
-> do
|
62
|
+
routes.route 'routing.key', to: 'test#index'
|
63
|
+
routes.route 'another.routing.key', to: 'test#index'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should only add one new route' do
|
68
|
+
expect { subject.call }.to change{ routes.routes.size }.from(0).to(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should add second binding to first route' do
|
72
|
+
subject.call
|
73
|
+
expect(routes.routes.first.keys).to have(2).items
|
74
|
+
expect(routes.routes.first.keys).to eq %w(routing.key another.routing.key)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#files' do
|
80
|
+
it 'should allow to add route paths' do
|
81
|
+
routes.files << 'abc.rb'
|
82
|
+
routes.files += %w(cde.rb edf.rb)
|
83
|
+
|
84
|
+
expect(routes.files).to eq %w(abc.rb cde.rb edf.rb)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'reload' do
|
89
|
+
before { File.stub(:exists?).and_return(true) }
|
90
|
+
|
91
|
+
it 'should trigger load for all files' do
|
92
|
+
expect(routes).to receive(:load).with('cde.rb').ordered
|
93
|
+
expect(routes).to receive(:load).with('edf.rb').ordered
|
94
|
+
routes.files += %w(cde.rb edf.rb)
|
95
|
+
routes.reload
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should clear old routes before reloading' do
|
99
|
+
routes.route 'abc', to: 'abc#test'
|
100
|
+
routes.reload
|
101
|
+
expect(routes.each).to have(0).items
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'load' do
|
106
|
+
let(:file) { 'spec/fixtures/msgr-routes-test-1.rb' }
|
107
|
+
|
108
|
+
it 'should eval given file within routes context' do
|
109
|
+
expect(routes).to receive(:route).with('abc.#', to: 'test#index')
|
110
|
+
routes.load file
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestConsumer < Msgr::Consumer
|
4
|
+
def index
|
5
|
+
puts "<<< #{payload}"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Msgr do
|
10
|
+
before do
|
11
|
+
Msgr.logger = nil;
|
12
|
+
Msgr.logger.level = Logger::Severity::DEBUG if Msgr.logger
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:client) { Msgr::Client.new size: 1, prefix: SecureRandom.hex(32) }
|
16
|
+
|
17
|
+
before do
|
18
|
+
client.routes.configure do
|
19
|
+
route '#', to: 'test#index'
|
20
|
+
end
|
21
|
+
|
22
|
+
client.start
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
client.stop timeout: 10, delete: true, wait_empty: 10
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should dispatch published methods to consumer' do
|
30
|
+
expect_any_instance_of(TestConsumer).to receive(:index).within(10).seconds.and_call_original
|
31
|
+
|
32
|
+
client.publish 'routing.key', 'Payload'
|
33
|
+
|
34
|
+
sleep 10
|
35
|
+
end
|
36
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# Bundler setup
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup :default, :test
|
4
|
+
|
1
5
|
# Coverage
|
2
6
|
require 'coveralls'
|
3
7
|
Coveralls.wear! do
|
@@ -5,6 +9,7 @@ Coveralls.wear! do
|
|
5
9
|
end
|
6
10
|
|
7
11
|
require 'rspec/autorun'
|
12
|
+
require 'rspec/message/within'
|
8
13
|
require 'msgr'
|
9
14
|
|
10
15
|
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
@@ -15,4 +20,14 @@ RSpec.configure do |config|
|
|
15
20
|
# Only allow expect syntax
|
16
21
|
c.syntax = :expect
|
17
22
|
end
|
23
|
+
|
24
|
+
config.before do
|
25
|
+
Celluloid.logger = nil
|
26
|
+
|
27
|
+
Celluloid.shutdown
|
28
|
+
Celluloid.boot
|
29
|
+
|
30
|
+
Celluloid.logger = nil
|
31
|
+
Msgr.logger = false
|
32
|
+
end
|
18
33
|
end
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
# Somewhere between
|
4
|
+
# `ruby -w -W2 -S rspec ...`
|
5
|
+
# and the rspec executable `bundle/setup` is required or
|
6
|
+
# `Bundler.setup` without groups called. This will let Bundler
|
7
|
+
# load ALL gems from ALL groups. This results in leaking
|
8
|
+
# gems only for rails integration tests into msgr testing
|
9
|
+
# environment.
|
10
|
+
#
|
11
|
+
# This file will be required by ruby on the commandline before
|
12
|
+
# everything else can kick in. The code snippet below will
|
13
|
+
# patch bundler to just ignore `setup` calls without
|
14
|
+
# specified groups. All test helper will explicit call
|
15
|
+
# `Bundler.setup` with required test groups.
|
16
|
+
|
17
|
+
module Bundler
|
18
|
+
class << self
|
19
|
+
alias :old_setup :setup
|
20
|
+
def setup(*groups)
|
21
|
+
old_setup(*groups) unless groups.empty?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Only load default group
|
27
|
+
Bundler.setup :default
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,49 +66,7 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
|
-
-
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: coveralls
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
description: ''
|
69
|
+
description: 'Msgr: Rails-like Messaging Framework'
|
112
70
|
email:
|
113
71
|
- jg@altimos.de
|
114
72
|
executables: []
|
@@ -118,6 +76,7 @@ files:
|
|
118
76
|
- .gitignore
|
119
77
|
- .travis.yml
|
120
78
|
- Gemfile
|
79
|
+
- Guardfile
|
121
80
|
- LICENSE.txt
|
122
81
|
- README.md
|
123
82
|
- Rakefile
|
@@ -127,22 +86,77 @@ files:
|
|
127
86
|
- lib/msgr/binding.rb
|
128
87
|
- lib/msgr/client.rb
|
129
88
|
- lib/msgr/connection.rb
|
89
|
+
- lib/msgr/consumer.rb
|
130
90
|
- lib/msgr/dispatcher.rb
|
131
91
|
- lib/msgr/errors.rb
|
132
92
|
- lib/msgr/logging.rb
|
133
93
|
- lib/msgr/message.rb
|
94
|
+
- lib/msgr/message/acknowledge.rb
|
134
95
|
- lib/msgr/pool.rb
|
96
|
+
- lib/msgr/railtie.rb
|
135
97
|
- lib/msgr/route.rb
|
136
98
|
- lib/msgr/routes.rb
|
137
99
|
- lib/msgr/version.rb
|
138
100
|
- msgr.gemspec
|
139
101
|
- scripts/simple_test.rb
|
140
|
-
- spec/msgr
|
141
|
-
- spec/
|
142
|
-
- spec/
|
143
|
-
- spec/
|
144
|
-
- spec/
|
145
|
-
- spec/
|
102
|
+
- spec/fixtures/msgr-routes-test-1.rb
|
103
|
+
- spec/integration/dummy/README.rdoc
|
104
|
+
- spec/integration/dummy/Rakefile
|
105
|
+
- spec/integration/dummy/app/assets/images/.keep
|
106
|
+
- spec/integration/dummy/app/assets/javascripts/application.js
|
107
|
+
- spec/integration/dummy/app/assets/stylesheets/application.css
|
108
|
+
- spec/integration/dummy/app/consumers/application_consumer.rb
|
109
|
+
- spec/integration/dummy/app/consumers/test_consumer.rb
|
110
|
+
- spec/integration/dummy/app/controllers/application_controller.rb
|
111
|
+
- spec/integration/dummy/app/controllers/concerns/.keep
|
112
|
+
- spec/integration/dummy/app/controllers/test_controller.rb
|
113
|
+
- spec/integration/dummy/app/helpers/application_helper.rb
|
114
|
+
- spec/integration/dummy/app/mailers/.keep
|
115
|
+
- spec/integration/dummy/app/models/.keep
|
116
|
+
- spec/integration/dummy/app/models/concerns/.keep
|
117
|
+
- spec/integration/dummy/app/views/layouts/application.html.erb
|
118
|
+
- spec/integration/dummy/bin/bundle
|
119
|
+
- spec/integration/dummy/bin/rails
|
120
|
+
- spec/integration/dummy/bin/rake
|
121
|
+
- spec/integration/dummy/config.ru
|
122
|
+
- spec/integration/dummy/config/application.rb
|
123
|
+
- spec/integration/dummy/config/boot.rb
|
124
|
+
- spec/integration/dummy/config/database.yml
|
125
|
+
- spec/integration/dummy/config/environment.rb
|
126
|
+
- spec/integration/dummy/config/environments/development.rb
|
127
|
+
- spec/integration/dummy/config/environments/production.rb
|
128
|
+
- spec/integration/dummy/config/environments/test.rb
|
129
|
+
- spec/integration/dummy/config/initializers/backtrace_silencers.rb
|
130
|
+
- spec/integration/dummy/config/initializers/filter_parameter_logging.rb
|
131
|
+
- spec/integration/dummy/config/initializers/inflections.rb
|
132
|
+
- spec/integration/dummy/config/initializers/mime_types.rb
|
133
|
+
- spec/integration/dummy/config/initializers/secret_token.rb
|
134
|
+
- spec/integration/dummy/config/initializers/session_store.rb
|
135
|
+
- spec/integration/dummy/config/initializers/wrap_parameters.rb
|
136
|
+
- spec/integration/dummy/config/locales/en.yml
|
137
|
+
- spec/integration/dummy/config/msgr.rb
|
138
|
+
- spec/integration/dummy/config/rabbitmq.yml
|
139
|
+
- spec/integration/dummy/config/routes.rb
|
140
|
+
- spec/integration/dummy/db/test.sqlite3
|
141
|
+
- spec/integration/dummy/lib/assets/.keep
|
142
|
+
- spec/integration/dummy/log/.keep
|
143
|
+
- spec/integration/dummy/public/404.html
|
144
|
+
- spec/integration/dummy/public/422.html
|
145
|
+
- spec/integration/dummy/public/500.html
|
146
|
+
- spec/integration/dummy/public/favicon.ico
|
147
|
+
- spec/integration/msgr/railtie_spec.rb
|
148
|
+
- spec/integration/msgr_spec.rb
|
149
|
+
- spec/integration/spec_helper.rb
|
150
|
+
- spec/msgr/msgr/client_spec.rb
|
151
|
+
- spec/msgr/msgr/connection_spec.rb
|
152
|
+
- spec/msgr/msgr/consumer_spec.rb
|
153
|
+
- spec/msgr/msgr/pool_spec.rb
|
154
|
+
- spec/msgr/msgr/route_spec.rb
|
155
|
+
- spec/msgr/msgr/routes_spec.rb
|
156
|
+
- spec/msgr/msgr_spec.rb
|
157
|
+
- spec/msgr/spec_helper.rb
|
158
|
+
- spec/msgr/support/.keep
|
159
|
+
- spec/support/setup.rb
|
146
160
|
homepage: https://github.com/jgraichen/msgr
|
147
161
|
licenses:
|
148
162
|
- MIT
|
@@ -163,14 +177,67 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
177
|
version: '0'
|
164
178
|
requirements: []
|
165
179
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.0.
|
180
|
+
rubygems_version: 2.0.3
|
167
181
|
signing_key:
|
168
182
|
specification_version: 4
|
169
|
-
summary: ''
|
183
|
+
summary: 'Msgr: Rails-like Messaging Framework'
|
170
184
|
test_files:
|
171
|
-
- spec/msgr
|
172
|
-
- spec/
|
173
|
-
- spec/
|
174
|
-
- spec/
|
175
|
-
- spec/
|
176
|
-
- spec/
|
185
|
+
- spec/fixtures/msgr-routes-test-1.rb
|
186
|
+
- spec/integration/dummy/README.rdoc
|
187
|
+
- spec/integration/dummy/Rakefile
|
188
|
+
- spec/integration/dummy/app/assets/images/.keep
|
189
|
+
- spec/integration/dummy/app/assets/javascripts/application.js
|
190
|
+
- spec/integration/dummy/app/assets/stylesheets/application.css
|
191
|
+
- spec/integration/dummy/app/consumers/application_consumer.rb
|
192
|
+
- spec/integration/dummy/app/consumers/test_consumer.rb
|
193
|
+
- spec/integration/dummy/app/controllers/application_controller.rb
|
194
|
+
- spec/integration/dummy/app/controllers/concerns/.keep
|
195
|
+
- spec/integration/dummy/app/controllers/test_controller.rb
|
196
|
+
- spec/integration/dummy/app/helpers/application_helper.rb
|
197
|
+
- spec/integration/dummy/app/mailers/.keep
|
198
|
+
- spec/integration/dummy/app/models/.keep
|
199
|
+
- spec/integration/dummy/app/models/concerns/.keep
|
200
|
+
- spec/integration/dummy/app/views/layouts/application.html.erb
|
201
|
+
- spec/integration/dummy/bin/bundle
|
202
|
+
- spec/integration/dummy/bin/rails
|
203
|
+
- spec/integration/dummy/bin/rake
|
204
|
+
- spec/integration/dummy/config.ru
|
205
|
+
- spec/integration/dummy/config/application.rb
|
206
|
+
- spec/integration/dummy/config/boot.rb
|
207
|
+
- spec/integration/dummy/config/database.yml
|
208
|
+
- spec/integration/dummy/config/environment.rb
|
209
|
+
- spec/integration/dummy/config/environments/development.rb
|
210
|
+
- spec/integration/dummy/config/environments/production.rb
|
211
|
+
- spec/integration/dummy/config/environments/test.rb
|
212
|
+
- spec/integration/dummy/config/initializers/backtrace_silencers.rb
|
213
|
+
- spec/integration/dummy/config/initializers/filter_parameter_logging.rb
|
214
|
+
- spec/integration/dummy/config/initializers/inflections.rb
|
215
|
+
- spec/integration/dummy/config/initializers/mime_types.rb
|
216
|
+
- spec/integration/dummy/config/initializers/secret_token.rb
|
217
|
+
- spec/integration/dummy/config/initializers/session_store.rb
|
218
|
+
- spec/integration/dummy/config/initializers/wrap_parameters.rb
|
219
|
+
- spec/integration/dummy/config/locales/en.yml
|
220
|
+
- spec/integration/dummy/config/msgr.rb
|
221
|
+
- spec/integration/dummy/config/rabbitmq.yml
|
222
|
+
- spec/integration/dummy/config/routes.rb
|
223
|
+
- spec/integration/dummy/db/test.sqlite3
|
224
|
+
- spec/integration/dummy/lib/assets/.keep
|
225
|
+
- spec/integration/dummy/log/.keep
|
226
|
+
- spec/integration/dummy/public/404.html
|
227
|
+
- spec/integration/dummy/public/422.html
|
228
|
+
- spec/integration/dummy/public/500.html
|
229
|
+
- spec/integration/dummy/public/favicon.ico
|
230
|
+
- spec/integration/msgr/railtie_spec.rb
|
231
|
+
- spec/integration/msgr_spec.rb
|
232
|
+
- spec/integration/spec_helper.rb
|
233
|
+
- spec/msgr/msgr/client_spec.rb
|
234
|
+
- spec/msgr/msgr/connection_spec.rb
|
235
|
+
- spec/msgr/msgr/consumer_spec.rb
|
236
|
+
- spec/msgr/msgr/pool_spec.rb
|
237
|
+
- spec/msgr/msgr/route_spec.rb
|
238
|
+
- spec/msgr/msgr/routes_spec.rb
|
239
|
+
- spec/msgr/msgr_spec.rb
|
240
|
+
- spec/msgr/spec_helper.rb
|
241
|
+
- spec/msgr/support/.keep
|
242
|
+
- spec/support/setup.rb
|
243
|
+
has_rdoc:
|
data/spec/msgr/client_spec.rb
DELETED
data/spec/msgr/routes_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Msgr::Routes do
|
4
|
-
let(:routes) { Msgr::Routes.new }
|
5
|
-
|
6
|
-
describe '#configure' do
|
7
|
-
let(:block) { Proc.new{} }
|
8
|
-
|
9
|
-
it 'should evaluate given block within instance context' do
|
10
|
-
expect(routes).to receive(:instance_eval).with { |p| p == block }
|
11
|
-
|
12
|
-
routes.configure &block
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should allow to call instance method in gven block' do
|
16
|
-
expect(routes).to receive(:test_instance_method).with(:abc)
|
17
|
-
|
18
|
-
routes.configure do
|
19
|
-
test_instance_method :abc
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#each' do
|
25
|
-
before do
|
26
|
-
routes.configure do
|
27
|
-
route 'abc.#', to: 'test#index'
|
28
|
-
route 'edf.#', to: 'test#index'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:each) { routes.each }
|
33
|
-
|
34
|
-
it 'should iterate over configured routes' do
|
35
|
-
expect(each).to have(2).items
|
36
|
-
|
37
|
-
expect(each.map(&:routing_key)).to be == %w(abc.# edf.#)
|
38
|
-
expect(each.map(&:consumer)).to be == %w(TestConsumer TestConsumer)
|
39
|
-
expect(each.map(&:action)).to be == %w(index index)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#route' do
|
44
|
-
let(:subject) { -> { routes.route 'routing.key', to: 'test2#index2' } }
|
45
|
-
let(:last_route) { routes.routes.last }
|
46
|
-
|
47
|
-
it 'should add a new route' do
|
48
|
-
expect { subject.call }.to change{ routes.routes.size }.from(0).to(1)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should add given route' do
|
52
|
-
subject.call
|
53
|
-
|
54
|
-
expect(last_route.routing_key).to eq 'routing.key'
|
55
|
-
expect(last_route.consumer).to eq 'Test2Consumer'
|
56
|
-
expect(last_route.action).to eq 'index2'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|