ruby_rabbitmq_janus 2.6.0.pre.229 → 2.6.0.pre.233

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 282be5ffe8733ceda9a4e8dda7cb471e57c510ecb92ad61fdebb0f64de87d5b0
4
- data.tar.gz: b22fe6c2d03b78e33ac892e430cbff70619cf211793834cd29252349b60269bf
3
+ metadata.gz: 61a24607524962f5c2048df2425b42c0ee8ffaced1bf2c553dd2af2a470b70f5
4
+ data.tar.gz: 2a20362980876f4da9671abf7340ef956a86a07b7b5bcf3d42894e15ae105055
5
5
  SHA512:
6
- metadata.gz: 786336d7f2e406f382101b9e1205fd684cce529f16d1a39f8c93930468ab57f7d9cce571581c896e677d86572c6a7bc1056cca69190b18b52a01a289baffc6d9
7
- data.tar.gz: a9872fd8111aba186a537fe85a2fe527b6fbdc577f0b05a197db04a6c968fa0ceb48bcbafd968518bb1956f0e81366bea5f771e592eeac0def5076365d6aa051
6
+ metadata.gz: 522688ed85f123d5028c885d56f97e937d4768cd76433b1d650001b3735fd98a7ae1a1fdf23bee512d41ef9394aed063c35d772cdb225322a7cbc27c6ac11a72
7
+ data.tar.gz: 6ebb7c8cd9a6dbbd5210e50adab615a53dfecce872f3777a3d1a816aae752ab90cf759f28d3df3236517061ae7152caa0120486449b2b767f5b03e35426a016b
data/lib/rrj/init.rb CHANGED
@@ -14,6 +14,9 @@ require 'erb'
14
14
 
15
15
  # Primary module for this gem
16
16
  module RubyRabbitmqJanus
17
+ # Constant used for checked if execution it's with RSpec
18
+ RRJ_RSPEC = false
19
+
17
20
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
18
21
 
19
22
  # # RubyRabbitmqJanus - RRJ
@@ -10,14 +10,22 @@ module RubyRabbitmqJanus
10
10
  class Connect
11
11
  # Initialize connection to server RabbitMQ
12
12
  def initialize
13
- @rabbit = Bunny.new(read_options_server.merge!(option_log_rabbit))
13
+ @rabbit = if RubyRabbitmqJanus::RRJ_RSPEC
14
+ BunnyMock.new.start
15
+ else
16
+ Bunny.new(read_options_server.merge!(option_log_rabbit))
17
+ end
14
18
  rescue => exception
15
19
  raise Errors::Rabbit::Connect::Initialize, exception
16
20
  end
17
21
 
18
22
  # Create an transaction with rabbitmq and close after response is received
19
23
  def transaction_short
20
- response = transaction_long { yield }
24
+ response = if RubyRabbitmqJanus::RRJ_RSPEC
25
+ fake_transaction
26
+ else
27
+ transaction_long { yield }
28
+ end
21
29
  close
22
30
  response
23
31
  rescue => exception
@@ -27,12 +35,16 @@ module RubyRabbitmqJanus
27
35
  # Create an transaction with rabbitmq and not close
28
36
  def transaction_long
29
37
  start
30
- yield
38
+ if RubyRabbitmqJanus::RRJ_RSPEC
39
+ @rabbit.channel.queue.pop[:message]
40
+ else
41
+ yield
42
+ end
31
43
  rescue => exception
32
44
  raise Errors::Rabbit::Connect::TransactionLong, exception
33
45
  end
34
46
 
35
- # Openning a connection with Rabbitmq
47
+ # Opening a connection with RabbitMQ
36
48
  def start
37
49
  @rabbit.start
38
50
  rescue => exception
@@ -48,13 +60,24 @@ module RubyRabbitmqJanus
48
60
 
49
61
  # Create an channel
50
62
  def channel
51
- @rabbit.create_channel
63
+ if RubyRabbitmqJanus::RRJ_RSPEC
64
+ @rabbit.channel
65
+ else
66
+ @rabbit.create_channel
67
+ end
52
68
  rescue => exception
53
69
  raise Errors::Rabbit::Connect::Channel, exception
54
70
  end
55
71
 
56
72
  private
57
73
 
74
+ def fake_transaction
75
+ channel = @rabbit.channel
76
+ queue = channel.queue 'janus-queue-test'
77
+ queue.publish 'RSpec testing message'
78
+ queue.pop
79
+ end
80
+
58
81
  def read_options_server
59
82
  conn = %w[host port pass user vhost]
60
83
  cfg = Tools::Config.instance.options['rabbit']
data/lib/rrj/rspec.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bunny-mock'
4
+
5
+ module RubyRabbitmqJanus
6
+ # Specify RSpec is used when gem is instantiate
7
+ RRJ_RSPEC = false
8
+
9
+ # # RRJRSpec
10
+ #
11
+ # Initializer to use with RSpec execution
12
+ class RRJRSpec < RRJTaskAdmin; end
13
+ end
@@ -5,6 +5,7 @@ require 'rrj/init'
5
5
  require 'rrj/admin'
6
6
  require 'rrj/task'
7
7
  require 'rrj/task_admin'
8
+ require 'rrj/rspec'
8
9
 
9
10
  # Define tools for this gems
10
11
  require 'rrj/tools/tools'
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,8 @@ end
26
26
  require_relative f
27
27
  end
28
28
 
29
+ RubyRabbitmqJanus::RRJ_RSPEC = false
30
+
29
31
  RSpec.configure do |config|
30
32
  DatabaseCleaner.strategy = :truncation
31
33
  ENV['MONGO'].match?('true') ? load_mongo : load_active_record
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0.pre.229
4
+ version: 2.6.0.pre.233
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-01 00:00:00.000000000 Z
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.2'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.2'
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: appraisal
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: aruba
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +154,16 @@ dependencies:
140
154
  name: mongoid
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - "~>"
157
+ - - ">="
144
158
  - !ruby/object:Gem::Version
145
- version: '5.2'
159
+ version: '0'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - "~>"
164
+ - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: '5.2'
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: overcommit
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +346,20 @@ dependencies:
332
346
  - - "~>"
333
347
  - !ruby/object:Gem::Version
334
348
  version: '2.5'
349
+ - !ruby/object:Gem::Dependency
350
+ name: bunny-mock
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '1.7'
356
+ type: :runtime
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '1.7'
335
363
  - !ruby/object:Gem::Dependency
336
364
  name: key_path
337
365
  requirement: !ruby/object:Gem::Requirement
@@ -536,6 +564,7 @@ files:
536
564
  - lib/rrj/rabbit/publisher/non_exclusive.rb
537
565
  - lib/rrj/rabbit/rabbit.rb
538
566
  - lib/rrj/railtie.rb
567
+ - lib/rrj/rspec.rb
539
568
  - lib/rrj/task.rb
540
569
  - lib/rrj/task_admin.rb
541
570
  - lib/rrj/tools/bin/arguments.rb