bunny-mock 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +12 -0
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +65 -0
- data/.travis.yml +6 -5
- data/.yardopts +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -11
- data/README.md +61 -88
- data/Rakefile +29 -0
- data/UPGRADING.md +12 -0
- data/bunny-mock.gemspec +19 -16
- data/lib/bunny-mock.rb +30 -29
- data/lib/bunny_mock/channel.rb +275 -274
- data/lib/bunny_mock/exchange.rb +258 -267
- data/lib/bunny_mock/exchanges/direct.rb +20 -19
- data/lib/bunny_mock/exchanges/fanout.rb +20 -23
- data/lib/bunny_mock/exchanges/headers.rb +27 -26
- data/lib/bunny_mock/exchanges/topic.rb +45 -49
- data/lib/bunny_mock/queue.rb +210 -209
- data/lib/bunny_mock/session.rb +171 -151
- data/lib/bunny_mock/version.rb +3 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/bunny_mock/exchange_spec.rb +10 -10
- data/spec/unit/bunny_mock/queue_spec.rb +7 -7
- data/spec/unit/bunny_mock/session_spec.rb +74 -48
- metadata +86 -14
- data/CHANGELOG +0 -8
- data/lib/bunny_mock/exceptions.rb +0 -16
@@ -1,79 +1,105 @@
|
|
1
1
|
describe BunnyMock::Session do
|
2
2
|
|
3
|
-
|
3
|
+
before do
|
4
|
+
@session = BunnyMock::Session.new
|
5
|
+
end
|
4
6
|
|
5
|
-
|
7
|
+
context '::new' do
|
6
8
|
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
9
|
+
it 'should start as not connected' do
|
10
10
|
|
11
|
-
|
11
|
+
expect(@session.status).to eq(:not_connected)
|
12
|
+
end
|
13
|
+
end
|
12
14
|
|
13
|
-
|
15
|
+
context '#start' do
|
14
16
|
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
17
|
+
it 'should set status to connected' do
|
18
18
|
|
19
|
-
|
19
|
+
expect(@session.start.status).to eq(:connected)
|
20
|
+
end
|
21
|
+
end
|
20
22
|
|
21
|
-
|
23
|
+
context '#stop (close)' do
|
22
24
|
|
23
|
-
|
25
|
+
it 'should set status to closed' do
|
24
26
|
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
27
|
+
@session.start
|
28
28
|
|
29
|
-
|
29
|
+
expect(@session.stop.status).to eq(:closed)
|
30
|
+
end
|
31
|
+
end
|
30
32
|
|
31
|
-
|
33
|
+
context '#open?' do
|
32
34
|
|
33
|
-
|
35
|
+
it 'should return true if status is open' do
|
34
36
|
|
35
|
-
|
36
|
-
end
|
37
|
+
@session.start
|
37
38
|
|
38
|
-
|
39
|
+
expect(@session.open?).to be_truthy
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
expect(@session.open?).to be_falsey
|
42
|
+
it 'should return false otherwise' do
|
42
43
|
|
43
|
-
|
44
|
+
expect(@session.status).to eq(:not_connected)
|
45
|
+
expect(@session.open?).to be_falsey
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
47
|
+
@session.start
|
48
|
+
@session.stop
|
49
49
|
|
50
|
-
|
50
|
+
expect(@session.status).to eq(:closed)
|
51
|
+
expect(@session.open?).to be_falsey
|
52
|
+
end
|
53
|
+
end
|
51
54
|
|
52
|
-
|
55
|
+
context '#create_channel (channel)' do
|
53
56
|
|
54
|
-
|
55
|
-
second = @session.create_channel
|
57
|
+
it 'should create a new channel with no arguments' do
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
first = @session.create_channel
|
60
|
+
second = @session.create_channel
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
+
expect(first.class).to eq(BunnyMock::Channel)
|
63
|
+
expect(second.class).to eq(BunnyMock::Channel)
|
62
64
|
|
63
|
-
|
65
|
+
expect(first).to_not eq(second)
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
second = @session.create_channel 1
|
68
|
+
it 'should return cached channel with same identifier' do
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
+
first = @session.create_channel 1
|
71
|
+
second = @session.create_channel 1
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
+
expect(first).to eq(second)
|
74
|
+
end
|
73
75
|
|
74
|
-
|
76
|
+
it 'should return an ArgumentError for reserved channel' do
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
expect { @session.create_channel(0) }.to raise_error(ArgumentError)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context '#with_channel' do
|
83
|
+
|
84
|
+
it 'should close the channel after the block ends' do
|
85
|
+
channel = nil
|
86
|
+
|
87
|
+
@session.with_channel { |c| channel = c }
|
88
|
+
|
89
|
+
expect(channel.closed?).to be_truthy
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should close the channel if an exception is raised' do
|
93
|
+
channel = nil
|
94
|
+
|
95
|
+
expect do
|
96
|
+
@session.with_channel do |c|
|
97
|
+
channel = c
|
98
|
+
raise 'Whoops!'
|
99
|
+
end
|
100
|
+
end.to raise_error('Whoops!')
|
101
|
+
|
102
|
+
expect(channel.closed?).to be_truthy
|
103
|
+
end
|
104
|
+
end
|
79
105
|
end
|
metadata
CHANGED
@@ -1,51 +1,123 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunny-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Rempe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bunny
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
23
58
|
requirements:
|
24
59
|
- - ">="
|
25
60
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.4.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.4.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
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'
|
27
97
|
description: Easy to use mocking for testing the Bunny client for RabbitMQ
|
28
98
|
email:
|
29
|
-
-
|
30
|
-
WVc1a2NtVjNjbVZ0Y0dWQVoyMWhhV3d1WTI5dFxu
|
99
|
+
- andrewrempe@gmail.com
|
31
100
|
executables: []
|
32
101
|
extensions: []
|
33
|
-
extra_rdoc_files:
|
34
|
-
- README.md
|
102
|
+
extra_rdoc_files: []
|
35
103
|
files:
|
36
104
|
- ".coveralls.yml"
|
105
|
+
- ".editorconfig"
|
37
106
|
- ".gitignore"
|
38
107
|
- ".rspec"
|
108
|
+
- ".rubocop.yml"
|
109
|
+
- ".rubocop_todo.yml"
|
39
110
|
- ".travis.yml"
|
40
111
|
- ".yardopts"
|
41
|
-
- CHANGELOG
|
112
|
+
- CHANGELOG.md
|
42
113
|
- Gemfile
|
43
114
|
- LICENSE
|
44
115
|
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- UPGRADING.md
|
45
118
|
- bunny-mock.gemspec
|
46
119
|
- lib/bunny-mock.rb
|
47
120
|
- lib/bunny_mock/channel.rb
|
48
|
-
- lib/bunny_mock/exceptions.rb
|
49
121
|
- lib/bunny_mock/exchange.rb
|
50
122
|
- lib/bunny_mock/exchanges/direct.rb
|
51
123
|
- lib/bunny_mock/exchanges/fanout.rb
|
@@ -83,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
155
|
version: '0'
|
84
156
|
requirements: []
|
85
157
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.5.1
|
87
159
|
signing_key:
|
88
160
|
specification_version: 4
|
89
161
|
summary: Mocking for the popular Bunny client for RabbitMQ
|
@@ -97,4 +169,4 @@ test_files:
|
|
97
169
|
- spec/unit/bunny_mock/queue_spec.rb
|
98
170
|
- spec/unit/bunny_mock/session_spec.rb
|
99
171
|
- spec/unit/bunny_mock_spec.rb
|
100
|
-
has_rdoc:
|
172
|
+
has_rdoc:
|
data/CHANGELOG
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module BunnyMock
|
2
|
-
|
3
|
-
##
|
4
|
-
# Base class for all exceptions
|
5
|
-
#
|
6
|
-
# @api public
|
7
|
-
#
|
8
|
-
class Exception < ::StandardError; end
|
9
|
-
|
10
|
-
##
|
11
|
-
# Raised when a queue or exchange is not found
|
12
|
-
#
|
13
|
-
# @api public
|
14
|
-
#
|
15
|
-
class NotFound < Exception; end
|
16
|
-
end
|