ruby_rabbitmq_janus 3.0.0.pre.354 → 3.0.0.pre.384
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -2
- data/lib/generators/ruby_rabbitmq_janus/migration_generator.rb +2 -0
- data/lib/rrj/errors/error.rb +1 -1
- data/lib/rrj/janus/responses/admin.rb +13 -9
- data/lib/rrj/janus/responses/error.rb +0 -2
- data/lib/rrj/janus/responses/rspec.rb +2 -0
- data/lib/rrj/janus/responses/standard.rb +1 -0
- data/lib/rrj/janus/transactions/handle.rb +2 -0
- data/lib/rrj/janus/transactions/rspec.rb +2 -0
- data/lib/rrj/janus/transactions/session.rb +1 -0
- data/lib/rrj/models/active_record.rb +3 -0
- data/lib/rrj/models/concerns/instances.rb +11 -6
- data/lib/rrj/process/concurrency.rb +15 -5
- data/lib/rrj/process/event.rb +7 -5
- data/lib/rrj/process/event_admin.rb +7 -5
- data/lib/rrj/process/thread_runner_concern.rb +30 -29
- data/lib/rrj/rabbit/base_event.rb +2 -2
- data/lib/rrj/rabbit/connect.rb +21 -4
- data/lib/rrj/rabbit/listener/base.rb +17 -1
- data/lib/rrj/rabbit/listener/from.rb +2 -15
- data/lib/rrj/rabbit/listener/from_admin.rb +2 -15
- data/lib/rrj/rabbit/publisher/non_exclusive.rb +3 -0
- data/lib/rrj/rails.rb +9 -5
- data/lib/rrj/rspec.rb +5 -0
- data/lib/rrj/task.rb +2 -0
- data/lib/rrj/tools/gem/config/gem.rb +1 -1
- data/lib/rrj/tools/gem/logger.rb +1 -2
- data/lib/rrj/tools/gem/requests.rb +2 -2
- data/spec/config/database.rb +1 -0
- data/spec/factories/janus_instance.rb +2 -0
- data/spec/ruby_rabbitmq_janus/janus/responses/errors_spec.rb +175 -0
- data/spec/ruby_rabbitmq_janus/janus/responses/response_spec.rb +1 -1
- data/spec/ruby_rabbitmq_janus/models/{janus_instance_definition_spec.rb → janus_instance_field_spec.rb} +0 -0
- data/spec/ruby_rabbitmq_janus/models/janus_instance_instance_spec.rb +47 -0
- data/spec/ruby_rabbitmq_janus/models/{janus_instance_spec.rb → janus_instance_validation_spec.rb} +10 -2
- data/spec/ruby_rabbitmq_janus/process/concurrencies/concurrency_spec.rb +1 -5
- data/spec/ruby_rabbitmq_janus/process/concurrencies/event_admin_spec.rb +3 -2
- data/spec/ruby_rabbitmq_janus/process/concurrencies/event_spec.rb +3 -2
- data/spec/ruby_rabbitmq_janus/rabbit/listener/from_spec.rb +1 -0
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/admin_spec.rb +1 -0
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/exclusive_spec.rb +4 -3
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/non_exclusive_spec.rb +4 -4
- data/spec/ruby_rabbitmq_janus/tools/logger_spec.rb +34 -0
- data/spec/ruby_rabbitmq_janus/tools/replaces/admin_spec.rb +2 -2
- data/spec/ruby_rabbitmq_janus/tools/replaces/handle_spec.rb +1 -1
- data/spec/ruby_rabbitmq_janus/tools/type_spec.rb +1 -1
- data/spec/spec_helper.rb +27 -3
- data/spec/support/examples_model.rb +45 -0
- data/spec/support/examples_thread.rb +21 -15
- data/tmp/coverage/assets/0.10.2/application.css +799 -0
- data/tmp/coverage/assets/0.10.2/application.js +1707 -0
- data/tmp/coverage/assets/0.10.2/colorbox/border.png +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/controls.png +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_green.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_red.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_yellow.png +0 -0
- data/tmp/coverage/assets/0.10.2/loading.gif +0 -0
- data/tmp/coverage/assets/0.10.2/magnify.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/tmp/coverage/index.html +21339 -0
- metadata +73 -10
|
@@ -36,7 +36,7 @@ module RubyRabbitmqJanus
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def opts_subs
|
|
39
|
-
{ block: false, manual_ack:
|
|
39
|
+
{ block: false, manual_ack: false, arguments: { 'x-priority': 2 } }
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def info_subscribe(info, _prop, payload)
|
|
@@ -51,6 +51,22 @@ module RubyRabbitmqJanus
|
|
|
51
51
|
raise Errors::Rabbit::Listener::ResponseEmpty, response \
|
|
52
52
|
if response.to_hash.size.zero?
|
|
53
53
|
end
|
|
54
|
+
|
|
55
|
+
def subscribe_queue
|
|
56
|
+
rabbit.prefetch(1)
|
|
57
|
+
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
|
58
|
+
info_subscribe(info, prop, payload)
|
|
59
|
+
synchronize_response(payload)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def synchronize_response(payload)
|
|
64
|
+
lock.synchronize do
|
|
65
|
+
response = response_class(payload)
|
|
66
|
+
responses.push(response)
|
|
67
|
+
end
|
|
68
|
+
semaphore.signal
|
|
69
|
+
end
|
|
54
70
|
end
|
|
55
71
|
end
|
|
56
72
|
end
|
|
@@ -15,21 +15,8 @@ module RubyRabbitmqJanus
|
|
|
15
15
|
rabbit.queue(Tools::Config.instance.queue_from)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
|
21
|
-
info_subscribe(info, prop, payload)
|
|
22
|
-
synchronize_response(info, payload)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def synchronize_response(info, payload)
|
|
27
|
-
lock.synchronize do
|
|
28
|
-
response = Janus::Responses::Event.new(JSON.parse(payload))
|
|
29
|
-
responses.push(response)
|
|
30
|
-
end
|
|
31
|
-
rabbit.acknowledge(info.delivery_tag, false)
|
|
32
|
-
semaphore.signal
|
|
18
|
+
def response_class(payload)
|
|
19
|
+
Janus::Responses::Event.new(JSON.parse(payload))
|
|
33
20
|
end
|
|
34
21
|
end
|
|
35
22
|
end
|
|
@@ -15,21 +15,8 @@ module RubyRabbitmqJanus
|
|
|
15
15
|
rabbit.queue(Tools::Config.instance.queue_admin_from)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
|
21
|
-
info_subscribe(info, prop, payload)
|
|
22
|
-
synchronize_response(info, payload)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def synchronize_response(info, payload)
|
|
27
|
-
lock.synchronize do
|
|
28
|
-
response = Janus::Responses::Admin.new(JSON.parse(payload))
|
|
29
|
-
responses.push(response)
|
|
30
|
-
end
|
|
31
|
-
rabbit.acknowledge(info.delivery_tag, false)
|
|
32
|
-
semaphore.signal
|
|
18
|
+
def response_class(payload)
|
|
19
|
+
Janus::Responses::Admin.new(JSON.parse(payload))
|
|
33
20
|
end
|
|
34
21
|
end
|
|
35
22
|
end
|
|
@@ -17,9 +17,12 @@ module RubyRabbitmqJanus
|
|
|
17
17
|
# Send an message to queue
|
|
18
18
|
#
|
|
19
19
|
# @param [String] request JSON request sending to rabbitmq queue
|
|
20
|
+
#
|
|
21
|
+
# rubocop:disable Lint/UselessMethodDefinition
|
|
20
22
|
def publish(request)
|
|
21
23
|
super(request)
|
|
22
24
|
end
|
|
25
|
+
# rubocop:enable Lint/UselessMethodDefinition
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
end
|
data/lib/rrj/rails.rb
CHANGED
|
@@ -25,11 +25,15 @@ module RubyRabbitmqJanus
|
|
|
25
25
|
actions = RubyRabbitmqJanus::ActionEvents.new.actions
|
|
26
26
|
admin_actions = RubyRabbitmqJanus::ActionAdminEvents.new.actions
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
listeners = []
|
|
29
|
+
(1..number).each do
|
|
30
|
+
listeners.push process::Event.new.run(&actions)
|
|
31
|
+
listeners.push process::EventAdmin.new.run(&admin_actions)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Parallel.each(listeners, in_processes: number) do |listener|
|
|
35
|
+
item = "[Item##{listener}]"
|
|
36
|
+
Log.warn "#{item}, Worker : #{Parallel.worker_number + 1} / #{number}"
|
|
33
37
|
end
|
|
34
38
|
end
|
|
35
39
|
end
|
data/lib/rrj/rspec.rb
CHANGED
|
@@ -9,20 +9,25 @@ module RubyRabbitmqJanus
|
|
|
9
9
|
#
|
|
10
10
|
# Initializer to use with RSpec execution
|
|
11
11
|
class RRJRSpec < RRJTaskAdmin
|
|
12
|
+
# rubocop:disable Lint/MissingSuper
|
|
12
13
|
def initialize
|
|
13
14
|
RubyRabbitmqJanus::Tools::Config.instance
|
|
14
15
|
end
|
|
16
|
+
# rubocop:enable Lint/MissingSuper
|
|
15
17
|
|
|
18
|
+
# @see RubyRabbitmqJanus::RRJ::session_endpoint_public
|
|
16
19
|
def session_endpoint_public(_options)
|
|
17
20
|
yield(RubyRabbitmqJanus::Janus::Transactions::RSpec.new)
|
|
18
21
|
end
|
|
19
22
|
|
|
23
|
+
# @see RubyRabbitmqJanus::RRJ::session_endpoint_private
|
|
20
24
|
def handle_endpoint_public(_options)
|
|
21
25
|
transaction = RubyRabbitmqJanus::Janus::Transactions::RSpec.new
|
|
22
26
|
yield(transaction)
|
|
23
27
|
transaction.response
|
|
24
28
|
end
|
|
25
29
|
|
|
30
|
+
# @see RubyRabbitmqJanus::RRJAdmin::admin_endpoint
|
|
26
31
|
def admin_endpoint(_options)
|
|
27
32
|
yield(RubyRabbitmqJanus::Janus::Transactions::RSpec.new)
|
|
28
33
|
end
|
data/lib/rrj/task.rb
CHANGED
|
@@ -9,10 +9,12 @@ module RubyRabbitmqJanus
|
|
|
9
9
|
#
|
|
10
10
|
# This class is used with rake task.
|
|
11
11
|
class RRJTask < RRJ
|
|
12
|
+
# rubocop:disable Lint/MissingSuper
|
|
12
13
|
def initialize
|
|
13
14
|
Tools::Config.instance
|
|
14
15
|
Tools::Requests.instance
|
|
15
16
|
end
|
|
17
|
+
# rubocop:enable Lint/MissingSuper
|
|
16
18
|
|
|
17
19
|
# Create a transaction between Apps and Janus in queue private
|
|
18
20
|
#
|
|
@@ -12,7 +12,7 @@ module RubyRabbitmqJanus
|
|
|
12
12
|
module ConfigGem
|
|
13
13
|
# @return [Boolean] Read option file for a janus cluster section
|
|
14
14
|
def cluster
|
|
15
|
-
@options['gem']['cluster']['enabled'].to_s.match?('true')
|
|
15
|
+
@options['gem']['cluster']['enabled'].to_s.match?('true')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# @return [Symbol] read configuration for log level used in this gem
|
data/lib/rrj/tools/gem/logger.rb
CHANGED
|
@@ -41,7 +41,6 @@ module RubyRabbitmqJanus
|
|
|
41
41
|
# Choose type logger used in application instance
|
|
42
42
|
def self.initialize_logger
|
|
43
43
|
case @config.log_type
|
|
44
|
-
when :stdout then logger_stdout
|
|
45
44
|
when :file then logger_file
|
|
46
45
|
when :remote then logger_remote
|
|
47
46
|
else
|
|
@@ -51,7 +50,7 @@ module RubyRabbitmqJanus
|
|
|
51
50
|
|
|
52
51
|
# Configure logger with output SDTOUT
|
|
53
52
|
def self.logger_stdout
|
|
54
|
-
::Logger.new(
|
|
53
|
+
::Logger.new($stdout)
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
# Configure logger with output file
|
|
@@ -32,9 +32,9 @@ module RubyRabbitmqJanus
|
|
|
32
32
|
def each_folder(subfolder)
|
|
33
33
|
Dir[File.join(PATH_REQUEST + subfolder, '*')].count do |file|
|
|
34
34
|
if File.file?(file)
|
|
35
|
-
read_folder(subfolder.gsub('/', '::')
|
|
35
|
+
read_folder("#{subfolder.gsub('/', '::')}::", file)
|
|
36
36
|
elsif File.directory?(file)
|
|
37
|
-
each_folder(subfolder
|
|
37
|
+
each_folder("#{subfolder}/#{File.basename(file)}")
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
data/spec/config/database.rb
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe RubyRabbitmqJanus::Janus::Responses::Errors, type: :responses,
|
|
6
|
+
name: :errors do
|
|
7
|
+
let(:message) do
|
|
8
|
+
{
|
|
9
|
+
'janus' => 'error',
|
|
10
|
+
'error' => {
|
|
11
|
+
'code' => number,
|
|
12
|
+
'reason' => reason
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
let(:response) { RubyRabbitmqJanus::Janus::Responses::Response.new(message) }
|
|
17
|
+
let(:error) { described_class.new }
|
|
18
|
+
let(:reason) { [*('a'..'z'), *('0'..'9')].sample(12).join }
|
|
19
|
+
|
|
20
|
+
context 'when 403' do
|
|
21
|
+
let(:number) { 403 }
|
|
22
|
+
|
|
23
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Unauthorized) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'when 405' do
|
|
27
|
+
let(:number) { 405 }
|
|
28
|
+
|
|
29
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnauthorizedPlugin) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'when 450' do
|
|
33
|
+
let(:number) { 450 }
|
|
34
|
+
|
|
35
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TransportSpecific) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'when 452' do
|
|
39
|
+
let(:number) { 452 }
|
|
40
|
+
|
|
41
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::MissingRequest) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'when 453' do
|
|
45
|
+
let(:number) { 453 }
|
|
46
|
+
|
|
47
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnknownRequest) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'when 454' do
|
|
51
|
+
let(:number) { 454 }
|
|
52
|
+
|
|
53
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidJSON) }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'when 455' do
|
|
57
|
+
let(:number) { 455 }
|
|
58
|
+
|
|
59
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidJSONObject) }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context 'when 456' do
|
|
63
|
+
let(:number) { 456 }
|
|
64
|
+
|
|
65
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::MissingMandatoryElement) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'when 457' do
|
|
69
|
+
let(:number) { 457 }
|
|
70
|
+
|
|
71
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidRequestPath) }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context 'when 458' do
|
|
75
|
+
let(:number) { 458 }
|
|
76
|
+
|
|
77
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::SessionNotFound) }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context 'when 459' do
|
|
81
|
+
let(:number) { 459 }
|
|
82
|
+
|
|
83
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::HandleNotFound) }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'when 460' do
|
|
87
|
+
let(:number) { 460 }
|
|
88
|
+
|
|
89
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginNotFound) }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'when 461' do
|
|
93
|
+
let(:number) { 461 }
|
|
94
|
+
|
|
95
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginAttach) }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context 'when 462' do
|
|
99
|
+
let(:number) { 462 }
|
|
100
|
+
|
|
101
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginMessage) }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'when 463' do
|
|
105
|
+
let(:number) { 463 }
|
|
106
|
+
|
|
107
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginDetach) }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context 'when 464' do
|
|
111
|
+
let(:number) { 464 }
|
|
112
|
+
|
|
113
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::JSEPUnknownType) }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context 'when 465' do
|
|
117
|
+
let(:number) { 465 }
|
|
118
|
+
|
|
119
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::JSEPInvalidSDP) }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context 'when 466' do
|
|
123
|
+
let(:number) { 466 }
|
|
124
|
+
|
|
125
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TrickleInvalidStream) }
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
context 'when 467' do
|
|
129
|
+
let(:number) { 467 }
|
|
130
|
+
|
|
131
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidElementType) }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context 'when 468' do
|
|
135
|
+
let(:number) { 468 }
|
|
136
|
+
|
|
137
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::SessionConflit) }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'when 469' do
|
|
141
|
+
let(:number) { 469 }
|
|
142
|
+
|
|
143
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnexpectedAnswer) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
context 'when 470' do
|
|
147
|
+
let(:number) { 470 }
|
|
148
|
+
|
|
149
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TokenNotFound) }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
context 'when 471' do
|
|
153
|
+
let(:number) { 471 }
|
|
154
|
+
|
|
155
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::WebRTCState) }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
context 'when 472' do
|
|
159
|
+
let(:number) { 472 }
|
|
160
|
+
|
|
161
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::NotAcceptingSession) }
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
context 'when 490' do
|
|
165
|
+
let(:number) { 490 }
|
|
166
|
+
|
|
167
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Unknown) }
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
context 'when error missing' do
|
|
171
|
+
let(:number) { 418 }
|
|
172
|
+
|
|
173
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Nok) }
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -14,7 +14,7 @@ describe RubyRabbitmqJanus::Janus::Responses::Response, type: :responses,
|
|
|
14
14
|
context 'when ask nice json response' do
|
|
15
15
|
let(:message) { { 'data' => { 'id' => (rand * 10_000).to_i } } }
|
|
16
16
|
|
|
17
|
-
it { expect(response.
|
|
17
|
+
it { expect(response.to_nice_json).to be_kind_of(String) }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
context 'when ask hash response' do
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
|
|
6
|
+
name: :janus_instance do
|
|
7
|
+
before do
|
|
8
|
+
instances
|
|
9
|
+
first
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:model) { described_class }
|
|
13
|
+
let(:size) { (rand * 5).to_i + 1 }
|
|
14
|
+
let(:first) { model.first }
|
|
15
|
+
let(:session_id) { first.session_id }
|
|
16
|
+
let(:id) { first.id }
|
|
17
|
+
|
|
18
|
+
context 'when Janus instances are activated.' do
|
|
19
|
+
let(:instances) { FactoryBot.create_list(:janus_instance, size) }
|
|
20
|
+
let(:count_enabled) { size }
|
|
21
|
+
let(:count_destroyed) { 0 }
|
|
22
|
+
let(:count_disabled) { 0 }
|
|
23
|
+
|
|
24
|
+
include_examples 'when disable an instance'
|
|
25
|
+
include_examples 'when enable an instance not change'
|
|
26
|
+
include_examples 'when destroys all disable instance'
|
|
27
|
+
include_examples 'when search by instance'
|
|
28
|
+
include_examples 'when search by session'
|
|
29
|
+
include_examples 'when search instance enabled'
|
|
30
|
+
include_examples 'when search instance disabled'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'when Janus instances are disabled.' do
|
|
34
|
+
let(:instances) { FactoryBot.create_list(:janus_instance, size, enable: false) }
|
|
35
|
+
let(:count_enabled) { 0 }
|
|
36
|
+
let(:count_destroyed) { size }
|
|
37
|
+
let(:count_disabled) { size }
|
|
38
|
+
|
|
39
|
+
include_examples 'when disable an instance not change'
|
|
40
|
+
include_examples 'when enable an instance'
|
|
41
|
+
include_examples 'when destroys all disable instance'
|
|
42
|
+
include_examples 'when search by instance'
|
|
43
|
+
include_examples 'when search by session'
|
|
44
|
+
include_examples 'when search instance enabled'
|
|
45
|
+
include_examples 'when search instance disabled'
|
|
46
|
+
end
|
|
47
|
+
end
|