ruby_rabbitmq_janus 2.2.0.pre.42 → 2.2.0.pre.159

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -102
  3. data/lib/generators/ruby_rabbitmq_janus/templates/initializer.rb +2 -1
  4. data/lib/generators/ruby_rabbitmq_janus/templates/migration.rb +1 -1
  5. data/lib/rrj/errors/janus/responses/standard.rb +7 -13
  6. data/lib/rrj/errors/tools/gem/cluster.rb +9 -13
  7. data/lib/rrj/errors/tools/gem/config.rb +18 -29
  8. data/lib/rrj/errors/tools/gem/log.rb +13 -20
  9. data/lib/rrj/janus/responses/standard.rb +0 -2
  10. data/lib/rrj/models/active_record.rb +10 -1
  11. data/lib/rrj/tools/gem/cluster.rb +0 -5
  12. data/lib/rrj/tools/gem/config.rb +3 -5
  13. data/lib/rrj/tools/gem/log.rb +1 -3
  14. data/spec/config/database.rb +27 -0
  15. data/spec/config/database.yml +8 -0
  16. data/spec/config/initializer.rb +16 -0
  17. data/spec/config/instance.rb +16 -0
  18. data/spec/config/mongoid.yml +12 -0
  19. data/spec/request/admin/request_set_locking_debug_spec.rb +1 -1
  20. data/spec/request/base/request_attach_spec.rb +5 -1
  21. data/spec/request/base/request_create_spec.rb +5 -1
  22. data/spec/request/base/request_destroy_spec.rb +5 -1
  23. data/spec/request/base/request_detach_spec.rb +1 -1
  24. data/spec/request/base/request_info_spec.rb +5 -1
  25. data/spec/request/base/request_keepalive_spec.rb +1 -1
  26. data/spec/request/peer/request_offer_spec.rb +2 -0
  27. data/spec/request/peer/request_trickle_spec.rb +1 -1
  28. data/spec/request/peer/request_trickles_spec.rb +1 -1
  29. data/spec/rrj/messages/messages_admin_spec.rb +1 -0
  30. data/spec/rrj/messages/messages_message_spec.rb +1 -1
  31. data/spec/rrj/models/{active_record_spec.rb → janus_instance.rb} +1 -6
  32. data/spec/rrj/rabbit/propertie_2_spec.rb +28 -0
  33. data/spec/rrj/rabbit/propertie_spec.rb +0 -24
  34. data/spec/rrj/responses/responses_admin_spec.rb +2 -0
  35. data/spec/rrj/tools/gem/rrj_cluster_spec.rb +24 -7
  36. data/spec/rrj/tools/gem/rrj_log_spec.rb +39 -11
  37. data/spec/spec_helper.rb +23 -76
  38. metadata +23 -4
  39. data/spec/rrj/models/mongoid_spec.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5f7f8a44b723ed992abbde848a25695bc35df85
4
- data.tar.gz: 1c4069bc56dd828876f35e3ed9041f78ee1addfd
3
+ metadata.gz: 00285c936506050da48005b5aa88d3d1a807033d
4
+ data.tar.gz: 4936bc5671f055b7916566c9c5bd538151ac8910
5
5
  SHA512:
6
- metadata.gz: 47cb62ccb6c9ae3c8fda9c57aa30e9aded8a2c75c28521b39338e5cbd68261975cb46cde52604f669484a6679c128ca93b48ea867472e998a7ea86b7b2d75d67
7
- data.tar.gz: 882fae4ab47b161503ed0ea8c7b7feb84bcd58bf02e020d71551f8b487278e245ef07c51a7cc4823ec417092fd171b12a8ff352579706dfb0fb7ca6118d8fa02
6
+ metadata.gz: 503a9222f16ea2e6b1cd67b5a0155dd884be45e866bca9186470b080540bfe608963054cde66f765c568acc2e70dfe62abd8469f4e79abefd7cd2b0679809957
7
+ data.tar.gz: d1983a18e3d50b7565ac64f872655f9f3a741f4214ea45d6a4483313c3bb4a268145d85cfc6a8939ee0f97de0943f47fe803cc9745ce4bd4727ac8f891bcbe03
data/Rakefile CHANGED
@@ -5,106 +5,4 @@ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- RSpec::Core::RakeTask.new(:no_request_spec) do |t|
9
- t.rspec_opts = '--tag ~type:request'
10
- end
11
-
12
- RSpec::Core::RakeTask.new(:info) do |t|
13
- t.rspec_opts = '--tag name:info'
14
- end
15
-
16
- RSpec::Core::RakeTask.new(:handle_info) do |t|
17
- t.rspec_opts = '--tag name:handle_info'
18
- end
19
-
20
- RSpec::Core::RakeTask.new(:handles) do |t|
21
- t.rspec_opts = '--tag name:handles'
22
- end
23
-
24
- RSpec::Core::RakeTask.new(:sessions) do |t|
25
- t.rspec_opts = '--tag name:sessions'
26
- end
27
-
28
- RSpec::Core::RakeTask.new(:set_locking_debug) do |t|
29
- t.rspec_opts = '--tag name:set_locking_debug'
30
- end
31
-
32
- RSpec::Core::RakeTask.new(:set_log_level) do |t|
33
- t.rspec_opts = '--tag name:set_log_level'
34
- end
35
-
36
- RSpec::Core::RakeTask.new(:tokens) do |t|
37
- t.rspec_opts = '--tag name:tokens'
38
- end
39
-
40
- RSpec::Core::RakeTask.new(:attach) do |t|
41
- t.rspec_opts = '--tag name:attach'
42
- end
43
-
44
- RSpec::Core::RakeTask.new(:create) do |t|
45
- t.rspec_opts = '--tag name:create'
46
- end
47
-
48
- RSpec::Core::RakeTask.new(:destroy) do |t|
49
- t.rspec_opts = '--tag name:destroy'
50
- end
51
-
52
- RSpec::Core::RakeTask.new(:detach) do |t|
53
- t.rspec_opts = '--tag name:detach'
54
- end
55
-
56
- RSpec::Core::RakeTask.new(:keepalive) do |t|
57
- t.rspec_opts = '--tag name:keepalive'
58
- end
59
-
60
- RSpec::Core::RakeTask.new(:offer) do |t|
61
- t.rspec_opts = '--tag name:offer'
62
- end
63
-
64
- RSpec::Core::RakeTask.new(:trickle) do |t|
65
- t.rspec_opts = '--tag name:trickle'
66
- end
67
-
68
- RSpec::Core::RakeTask.new(:trickles) do |t|
69
- t.rspec_opts = '--tag name:trickles'
70
- end
71
-
72
- RSpec::Core::RakeTask.new(:type_tools) do |t|
73
- t.rspec_opts = '--tag type:tools'
74
- end
75
-
76
- RSpec::Core::RakeTask.new(:type_cluster) do |t|
77
- t.rspec_opts = '--tag type:cluster'
78
- end
79
-
80
- RSpec::Core::RakeTask.new(:type_config) do |t|
81
- t.rspec_opts = '--tag type:config'
82
- end
83
-
84
- RSpec::Core::RakeTask.new(:type_responses) do |t|
85
- t.rspec_opts = '--tag type:responses'
86
- end
87
-
88
- RSpec::Core::RakeTask.new(:type_rabbit) do |t|
89
- t.rspec_opts = '--tag type:rabbit'
90
- end
91
-
92
- RSpec::Core::RakeTask.new(:type_message) do |t|
93
- t.rspec_opts = '--tag type:message'
94
- end
95
-
96
- RSpec::Core::RakeTask.new(:except_request) do |t|
97
- t.rspec_opts = '--tag ~type:request'
98
- end
99
-
100
- RSpec::Core::RakeTask.new(:instances) do |t|
101
- t.rspec_opts = '--tag instances:true'
102
- end
103
-
104
8
  task default: :spec
105
-
106
- task all: [:info, :handle_info, :sessions, :set_locking_debug,
107
- :set_log_level, :tokens, :attach, :create, :destroy,
108
- :detach, :keepalive, :offer, :trickle, :trickles,
109
- :except_request]
110
- task two_instances: :instances
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # This test disable this gems execution when you running an task with rake
4
- if File.basename($PROGRAM_NAME) == 'rake'
4
+ # or if your start a Rails Console
5
+ if File.basename($PROGRAM_NAME).match?('rake') || defined?(::Rails::Console)
5
6
  # Configure RRJ for rake task
6
7
  ::RRJ = RubyRabbitmqJanus::RRJTask.new
7
8
  else
@@ -9,7 +9,7 @@ class CreateRubyRabbitmqJanusTables < ActiveRecord::Migration[5.0]
9
9
  table.integer :instance
10
10
  table.integer :session, limit: 8
11
11
  table.boolean :enable
12
- table.boolean :thread
12
+ table.integer :thread, limit: 8
13
13
  end
14
14
  end
15
15
  end
@@ -6,50 +6,44 @@ module RubyRabbitmqJanus
6
6
  # Define a super class for Janus::Responses::ResponseStandard
7
7
  class BaseResponseStandard < BaseResponse
8
8
  def initialize(message, level = :fatal)
9
- super "[Response] #{message}", level
9
+ super "[Response]#{message}", level
10
10
  end
11
11
  end
12
12
 
13
13
  module ResponseStandard
14
- # Error for Janus::Responses::ResponseStandard#initialize
15
14
  class Session < BaseResponseStandard
16
15
  def initialize
17
- super 'Error reading response session (data_id in response)'
16
+ super '[Session] Error reading response session (data_id in response)'
18
17
  end
19
18
  end
20
19
 
21
- # Error for Janus::Responses::ResponseStandard#session_id
22
20
  class SessionId < BaseResponseStandard
23
21
  def initialize
24
- super 'Error reading response session_id'
22
+ super '[SessionId] Error reading response session_id'
25
23
  end
26
24
  end
27
25
 
28
- # Error for Janus::Responses::ResponseStandard#plugin
29
26
  class Plugin < BaseResponseStandard
30
27
  def initialize
31
- super 'Error reading response plugin'
28
+ super '[Plugin] Error reading response plugin'
32
29
  end
33
30
  end
34
31
 
35
- # Error for Janus::Responses::ResponseStandard#plugin_data
36
32
  class PluginData < BaseResponseStandard
37
33
  def initialize
38
- super 'Error reading response plugin data'
34
+ super '[PluginData] Error reading response plugin data'
39
35
  end
40
36
  end
41
37
 
42
- # Error for Janus::Responses::ResponseStandard#data
43
38
  class Data < BaseResponseStandard
44
39
  def initialize
45
- super 'Error reading response data'
40
+ super '[Data] Error reading response data'
46
41
  end
47
42
  end
48
43
 
49
- # Error for Janus::Responses::ResponseStandard#sdp
50
44
  class SDP < BaseResponseStandard
51
45
  def initialize
52
- super 'Error reading SDP (jsep > sdp in response)'
46
+ super '[SDP] Error reading SDP (jsep > sdp in response)'
53
47
  end
54
48
  end
55
49
  end
@@ -6,36 +6,32 @@ module RubyRabbitmqJanus
6
6
  # Define a super class for all error in Tools::Option class
7
7
  class BaseCluster < BaseTools
8
8
  def initialize(message, level = :fatal)
9
- super("[Cluster] #{message}", level)
9
+ super("[Cluster]#{message}", level)
10
10
  end
11
11
  end
12
12
 
13
13
  module Cluster
14
- # Error for Tools::Option#initialize
15
- class Initializer < RubyRabbitmqJanus::Errors::Tools::BaseCluster
14
+ class CreateSession < RubyRabbitmqJanus::Errors::Tools::BaseCluster
16
15
  def initialize
17
- super 'Error in initializer', :fatal
16
+ super '[CreateSession] Error during create session (just one instance to Janus)'
18
17
  end
19
18
  end
20
19
 
21
- # Error for Tools::Option#queue_to
22
20
  class QueueTo < RubyRabbitmqJanus::Errors::Tools::BaseCluster
23
- def initalize
24
- super 'Error for create string queue_to'
21
+ def initialize
22
+ super '[QueueTo] Error for create string queue_to'
25
23
  end
26
24
  end
27
25
 
28
- # Error for Tools::Option#queue_admin_to
29
26
  class QueueAdminTo < RubyRabbitmqJanus::Errors::Tools::BaseCluster
30
- def initalize
31
- super 'Error for create string queue_admin_to'
27
+ def initialize
28
+ super '[QueueAdminTo] Error for create string queue_admin_to'
32
29
  end
33
30
  end
34
31
 
35
- # Error if restart thread to instance failed
36
32
  class RestartInstance < RubyRabbitmqJanus::Errors::Tools::BaseCluster
37
- def initialize(option)
38
- super "Error for restart thread to instance #{option}"
33
+ def initialize
34
+ super '[RestartInstance] Error for restart Janus Instance'
39
35
  end
40
36
  end
41
37
  end
@@ -5,75 +5,64 @@
5
5
  module RubyRabbitmqJanus
6
6
  module Errors
7
7
  module Tools
8
- # Define a super class for all error in class Config
9
8
  class BaseConfig < BaseTools
10
9
  def initialize(message, level = :fatal)
11
- super("[Config] #{message}", level)
10
+ super("[Config]#{message}", level)
12
11
  end
13
12
  end
14
13
 
15
14
  module Config
16
- # Error for Tools::Config#initialize
17
- class Initialize < RubyRabbitmqJanus::Errors::Tools::BaseConfig
18
- def initialize
19
- super 'Error in initalizer'
20
- end
21
- end
22
-
23
- # Error for Tools::Config#queue_from
24
15
  class QueueFrom < RubyRabbitmqJanus::Errors::Tools::BaseConfig
25
16
  def initialize
26
- super 'Error for reading standard queue from'
17
+ super '[QueueFrom] Error for reading standard queue from'
27
18
  end
28
19
  end
29
20
 
30
- # Error for Tools::Config#queue_to
31
21
  class QueueTo < RubyRabbitmqJanus::Errors::Tools::BaseConfig
32
22
  def initialize
33
- super 'Error for reading standard queue to'
23
+ super '[QueueTo] Error for reading standard queue to'
34
24
  end
35
25
  end
36
26
 
37
- # Error for config#queue_admin_from
38
27
  class QueueAdminFrom < RubyRabbitmqJanus::Errors::Tools::BaseConfig
39
28
  def initialize
40
- super 'Error for reading admin queue from'
29
+ super '[QueueAdminFrom] Error for reading admin queue from'
41
30
  end
42
31
  end
43
32
 
44
- # Error for Tools::Config#queue_admin_to
45
33
  class QueueAdminTo < RubyRabbitmqJanus::Errors::Tools::BaseConfig
46
34
  def initialize
47
- super 'Error for reading admin queue to'
35
+ super '[QueueAdminTo] Error for reading admin queue to'
48
36
  end
49
37
  end
50
38
 
51
- # Error for Tools::Config#log_level
52
- class LevelNotDefine < RubyRabbitmqJanus::Errors::Tools::BaseConfig
39
+ class LogLevel < RubyRabbitmqJanus::Errors::Tools::BaseConfig
53
40
  def initialize
54
- super 'Error for reading option level', :warn
41
+ super '[LogLevel] Error for reading option level', :warn
55
42
  end
56
43
  end
57
44
 
58
- # Error for Tools::Config#log_level
59
- class LevelRabbitMissing < RubyRabbitmqJanus::Errors::Tools::BaseConfig
45
+ class LogLevelRabbit < RubyRabbitmqJanus::Errors::Tools::BaseConfig
60
46
  def initialize
61
- super 'Error for reading option level for rabbitmq', :warn
47
+ super '[LogLevelRabbit] Error for reading option level for rabbitmq', :warn
62
48
  end
63
49
  end
64
50
 
65
- # Error for Tools::Config#time_to_live (or #ttl)
66
- class TTLNotFound < RubyRabbitmqJanus::Errors::Tools::BaseConfig
51
+ class TimeToLive < RubyRabbitmqJanus::Errors::Tools::BaseConfig
67
52
  def initialize
68
- super 'Keepalive TTL option is not reading in config file', :warn
53
+ super '[TimeToLive] Keepalive TTL option is not reading in config file', :warn
69
54
  end
70
55
  end
71
56
 
72
- # Error for Tools::Config#plugin_at
73
57
  class PluginAt < RubyRabbitmqJanus::Errors::Tools::BaseConfig
74
58
  def initialize(parameter)
75
- super 'Plugin is not found in configuration file, ' \
76
- "with parameter #{parameter}", :warn
59
+ super "[PluginAt] Plugin is not found in configuration file, with parameter #{parameter}", :warn
60
+ end
61
+ end
62
+
63
+ class Cluster < RubyRabbitmqJanus::Errors::Tools::BaseConfig
64
+ def initialize(parameter)
65
+ super '[Cluster] Cluster parameter is missing', :warn
77
66
  end
78
67
  end
79
68
  end
@@ -1,83 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
4
+
3
5
  module RubyRabbitmqJanus
4
6
  module Errors
5
7
  module Tools
6
- # Define super class for all errors in Log class
7
8
  class BaseLog < BaseTools
8
9
  def initialize(message, level = :warn)
9
- super("[Log] #{message}", level)
10
+ super("[Log]#{message}", level)
10
11
  end
11
12
  end
12
13
 
13
14
  module Log
14
- # Error for Tools::Log#initialize
15
- class Initialize < RubyRabbitmqJanus::Errors::Tools::BaseLog
16
- def initialize
17
- super 'Error in initializer', :fatal
18
- end
19
- end
20
-
21
- # Error for Tools::Log#unknow
22
- class Unknow < RubyRabbitmqJanus::Errors::Tools::BaseLog
15
+ class Unknown < RubyRabbitmqJanus::Errors::Tools::BaseLog
23
16
  def initialize
24
- super 'Error for writing in logger with level :unknown'
17
+ super '[Unknown] Error for writing in logger with level :unknown'
25
18
  end
26
19
  end
27
20
 
28
21
  # Error for Tools::Log#fatal
29
22
  class Fatal < RubyRabbitmqJanus::Errors::Tools::BaseLog
30
23
  def initialize
31
- super 'Error for writing in logger with level :fatal'
24
+ super '[Fatal] Error for writing in logger with level :fatal'
32
25
  end
33
26
  end
34
27
 
35
28
  # Error for Tools::Log#error
36
29
  class Error < RubyRabbitmqJanus::Errors::Tools::BaseLog
37
30
  def initialize
38
- super 'Error for writing in logger with level :error'
31
+ super '[Error] Error for writing in logger with level :error'
39
32
  end
40
33
  end
41
34
 
42
35
  # Error for Tools::Log#warn
43
36
  class Warn < RubyRabbitmqJanus::Errors::Tools::BaseLog
44
37
  def initialize
45
- super 'Error for writing in logger with level :warning'
38
+ super '[Warn] Error for writing in logger with level :warning'
46
39
  end
47
40
  end
48
41
 
49
42
  # Error for Tools::Log#info
50
43
  class Info < RubyRabbitmqJanus::Errors::Tools::BaseLog
51
44
  def initialize
52
- super 'Error for writing in logger with level :nfo'
45
+ super '[Info] Error for writing in logger with level :nfo'
53
46
  end
54
47
  end
55
48
 
56
49
  # Error for Tools::Log#debug
57
50
  class Debug < RubyRabbitmqJanus::Errors::Tools::BaseLog
58
51
  def initialize
59
- super 'Error for writing in logger with level :debug'
52
+ super '[Debug] Error for writing in logger with level :debug'
60
53
  end
61
54
  end
62
55
 
63
56
  # Error for Tools::Log#logger
64
57
  class Logger < RubyRabbitmqJanus::Errors::Tools::BaseLog
65
58
  def initialize
66
- super 'Error return logger to instance'
59
+ super '[Logger] Error return logger to instance'
67
60
  end
68
61
  end
69
62
 
70
63
  # Error for Tools::Log#logdev
71
64
  class Logdev < RubyRabbitmqJanus::Errors::Tools::BaseLog
72
65
  def initialize
73
- super 'Error filname to logger instance'
66
+ super '[Logdev] Error filname to logger instance'
74
67
  end
75
68
  end
76
69
 
77
70
  # Error for Tools::Log#save_level
78
71
  class SaveLevel < RubyRabbitmqJanus::Errors::Tools::BaseLog
79
72
  def initialize
80
- super 'Error for changing log level'
73
+ super '[SaveLevel] Error for changing log level'
81
74
  end
82
75
  end
83
76
  end
@@ -54,8 +54,6 @@ module RubyRabbitmqJanus
54
54
 
55
55
  def data_id
56
56
  data['id'].to_i
57
- rescue => error
58
- raise Errors::JanusResponseDataId, error
59
57
  end
60
58
  end
61
59
  end
@@ -10,9 +10,18 @@ module RubyRabbitmqJanus
10
10
  include RubyRabbitmqJanus::Models::JanusInstanceMethods
11
11
  include RubyRabbitmqJanus::Models::JanusInstanceValidations
12
12
 
13
- after_create { callback_after_after }
13
+ after_create { callback_create_after }
14
14
  after_update { callback_update_after }
15
15
  after_destroy { callback_destroy_after }
16
+
17
+ private
18
+
19
+ # Update attributes to document
20
+ #
21
+ # @param [Hash] List of attribute to update with this value
22
+ def set(attributes)
23
+ update_columns(attributes)
24
+ end
16
25
  end
17
26
  end
18
27
  end
@@ -8,14 +8,9 @@ module RubyRabbitmqJanus
8
8
  class Cluster
9
9
  include Singleton
10
10
 
11
- attr_reader :sessions
12
-
13
11
  # Initialize object for managing each instance to Janus
14
12
  def initialize
15
13
  @current_instance = nil
16
- @sessions = []
17
- rescue
18
- raise Errors::Tools::Cluster::Initializer
19
14
  end
20
15
 
21
16
  # Create session (just one Janus Instance)
@@ -35,8 +35,6 @@ module RubyRabbitmqJanus
35
35
  loading_configuration_customize
36
36
  loading_configuration_default
37
37
  Tools::Log.instance.save_level(log_level)
38
- rescue
39
- raise Errors::Tools::Config::Initialize
40
38
  end
41
39
 
42
40
  # Get to name queue_from (pattern)
@@ -79,13 +77,13 @@ module RubyRabbitmqJanus
79
77
  def log_level
80
78
  @options['gem']['log']['level'].upcase.to_sym || :INFO
81
79
  rescue
82
- raise Errors::Tools::Config::LevelNotDefine
80
+ raise Errors::Tools::Config::LogLevel
83
81
  end
84
82
 
85
83
  def log_level_rabbit
86
84
  @options['rabbit']['level'].upcase.to_sym || :INFO
87
85
  rescue
88
- raise Errors::Tools::Config::LevelNotDefine
86
+ raise Errors::Tools::Config::LogLevelRabbit
89
87
  end
90
88
 
91
89
  # @return [Integer]
@@ -93,7 +91,7 @@ module RubyRabbitmqJanus
93
91
  def time_to_live
94
92
  @options['janus']['session']['keepalive'].to_i || 50
95
93
  rescue
96
- raise Errors::Tools::Config::TTLNotFound
94
+ raise Errors::Tools::Config::TimeToLive
97
95
  end
98
96
 
99
97
  alias ttl time_to_live
@@ -40,8 +40,6 @@ module RubyRabbitmqJanus
40
40
  @level = logs.level
41
41
  @progname = logs.progname
42
42
  @logs = ActiveSupport::TaggedLogging.new(logs)
43
- rescue
44
- raise Errors::Tools::Log::Initialize
45
43
  end
46
44
 
47
45
  # Write a message in log with a `UNKNOWN` level
@@ -50,7 +48,7 @@ module RubyRabbitmqJanus
50
48
  def unknown(message)
51
49
  write_tag { @logs.unknown(filter(message)) }
52
50
  rescue
53
- raise Errors::Tools::Log::Unknow
51
+ raise Errors::Tools::Log::Unknown
54
52
  end
55
53
 
56
54
  # Write a message in log with a `FATAL` level
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ def load_active_record
4
+ # Configure active record
5
+ active_record = YAML::load(File.open('./spec/config/database.yml'))
6
+
7
+ # Connect to database
8
+ ActiveRecord::Base.establish_connection(active_record)
9
+ unless ActiveRecord::Base.connection.table_exists? 'janus_instances'
10
+ ActiveRecord::Base.connection.create_table(:janus_instances) do |table|
11
+ table.integer :instance
12
+ table.integer :session, limit: 8
13
+ table.boolean :enable
14
+ table.integer :thread, limit: 8
15
+ end
16
+ end
17
+ end
18
+
19
+ def load_mongo
20
+ # DatabaseCleaner[:mongoid, { connection: :test }]
21
+ Mongoid.load!('./spec/config/mongoid.yml', :test)
22
+ end
23
+
24
+ def after_load_database
25
+ DatabaseCleaner.clean
26
+ create_janus_instances
27
+ end
@@ -0,0 +1,8 @@
1
+ ---
2
+
3
+ # Used for Activerecord in spec
4
+
5
+ adapter: :sqlite3
6
+ encoding: utf-8
7
+ database: ':memory:'
8
+ timeout: 5000
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Test events response
4
+ class EventTest
5
+ def actions
6
+ lambda do |reason, payload|
7
+ RubyRabbitmqJanus::Tools::Log.instance.info "Reason : #{reason}"
8
+ RubyRabbitmqJanus::Tools::Log.instance.info "Payload : #{payload}"
9
+ end
10
+ end
11
+ end
12
+
13
+ # Initialize listener
14
+ actions = EventTest.new.actions
15
+ @event = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance
16
+ @event.run(&actions)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ def create_janus_instances
4
+ instance = RubyRabbitmqJanus::Models::JanusInstance
5
+
6
+ (1..2).each do |number|
7
+ instance.create!(instance: number, enable: true)
8
+ end
9
+ end
10
+
11
+ def find_instance
12
+ ji = RubyRabbitmqJanus::Models::JanusInstance.first
13
+ @session = { 'session_id' => ji.session }
14
+ @instance = { 'instance' => ji.instance }
15
+ @session_instance = @session.merge(@instance)
16
+ end
@@ -0,0 +1,12 @@
1
+ ---
2
+
3
+ # Used for MongoID in spec
4
+
5
+ test:
6
+ clients:
7
+ default:
8
+ database: rrj_test
9
+ hosts:
10
+ - mongo:27017
11
+ options:
12
+ raise_not_found_error: true
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- message type set locking debug' do
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type set locking debug', broken: true do
6
6
  before(:example) do
7
7
  @type = 'admin::set_locking_debug'
8
8
  @options = { 'debug' => [true, false].sample }
@@ -3,7 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ -- message type attach' do
6
- before(:example) { @type = 'base::attach' }
6
+ before(:example) do
7
+ @gateway = RubyRabbitmqJanus::RRJ.new
8
+
9
+ @type = 'base::attach'
10
+ end
7
11
 
8
12
  describe '#start_transaction', type: :request,
9
13
  level: :base,
@@ -3,7 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ -- message type create' do
6
- before(:example) { @type = 'base::create' }
6
+ before(:example) do
7
+ @gateway = RubyRabbitmqJanus::RRJ.new
8
+
9
+ @type = 'base::create'
10
+ end
7
11
 
8
12
  describe '#start_transaction', type: :request,
9
13
  level: :base,
@@ -3,7 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ -- message type destroy' do
6
- before(:example) { @type = 'base::destroy' }
6
+ before(:example) do
7
+ @gateway = RubyRabbitmqJanus::RRJ.new
8
+
9
+ @type = 'base::destroy'
10
+ end
7
11
 
8
12
  describe '#start_transaction', type: :request,
9
13
  level: :base,
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- mesage type detach' do
5
+ describe 'RubyRabbitmqJanus::RRJ -- mesage type detach', broken: true do
6
6
  before(:example) { @type = 'base::detach' }
7
7
 
8
8
  describe '#start_transaction_handle', type: :request,
@@ -3,7 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ -- message type info' do
6
- before(:example) { @type = 'base::info' }
6
+ before(:example) do
7
+ @gateway = RubyRabbitmqJanus::RRJ.new
8
+
9
+ @type = 'base::info'
10
+ end
7
11
 
8
12
  describe '#start_transaction', type: :request,
9
13
  level: :base,
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- message type keepalive' do
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type keepalive', broken: true do
6
6
  before(:example) { @type = 'base::keepalive' }
7
7
 
8
8
  describe '#start_transaction', type: :request,
@@ -4,6 +4,8 @@ require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ -- message type offer', broken: true do
6
6
  before(:example) do
7
+ @gateway = RubyRabbitmqJanus::RRJ.new
8
+
7
9
  @type = 'peer::offer'
8
10
  @options = {
9
11
  'sdp' => <<-SDP
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- message type trickle' do
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type trickle', broken: true do
6
6
  before(:example) do
7
7
  @type = 'peer::trickle'
8
8
  candidate = { 'sdpMid' => '..', 'sdpMLineIndex' => 1, 'candidate' => '..' }
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- message type trickles' do
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type trickles', broken: true do
6
6
  before(:example) do
7
7
  @type = 'peer::trickle'
8
8
  candidate = { 'sdpMid' => '..', 'sdpMLineIndex' => 1, 'candidate' => '..' }
@@ -3,6 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe RubyRabbitmqJanus::Janus::Messages::Admin, type: :messages,
6
+ level: :admin,
6
7
  name: :admin do
7
8
  let(:template) { 'base::info' }
8
9
  let(:msg_new) { RubyRabbitmqJanus::Janus::Messages::Admin.new(template) }
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe RubyRabbitmqJanus::Janus::Messages::Message, type: :messages,
6
6
  name: :message do
7
- before { gateway }
7
+ before { @gateway }
8
8
  let(:template) { 'base::info' }
9
9
  let(:msg_new) { RubyRabbitmqJanus::Janus::Messages::Message.new(template) }
10
10
 
@@ -4,15 +4,10 @@ require 'spec_helper'
4
4
 
5
5
  describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
6
6
  name: :janus_instance do
7
- before do
8
- Object.send(:remove_const, :Mongoid) if defined?(Mongoid)
9
- require 'active_record' unless defined?(ActiveRecord::Core)
10
- end
11
-
12
7
  let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
13
8
 
14
9
  context 'active record model' do
15
- it { expect(model.attribute_names).to include('id') }
10
+ it { expect(model.attribute_names).to include(ENV['MONGO'].match?('true') ? '_id' : 'id') }
16
11
  it { expect(model.attribute_names).to include('instance') }
17
12
  it { expect(model.attribute_names).to include('session') }
18
13
  it { expect(model.attribute_names).to include('enable') }
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RubyRabbitmqJanus::Rabbit::Propertie, type: :rabbit,
6
+ name: :propertie do
7
+ let(:rabbit) { RubyRabbitmqJanus::Rabbit::Propertie.new }
8
+
9
+ describe '#options' do
10
+ it { expect(rabbit.options).to match_json_schema(:rabbit_options) }
11
+ end
12
+
13
+ describe '#options_admin' do
14
+ context 'For admin request' do
15
+ it do
16
+ expect(rabbit.options_admin('admin::sessions')).to \
17
+ match_json_schema(:rabbit_options_admin)
18
+ end
19
+ end
20
+
21
+ context 'For base request' do
22
+ it do
23
+ expect(rabbit.options_admin('request::create')).to \
24
+ match_json_schema(:rabbit_options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,30 +2,6 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe RubyRabbitmqJanus::Rabbit::Propertie, type: :rabbit,
6
- name: :propertie do
7
- let(:rabbit) { RubyRabbitmqJanus::Rabbit::Propertie.new }
8
-
9
- describe '#options' do
10
- it { expect(rabbit.options).to match_json_schema(:rabbit_options) }
11
- end
12
-
13
- describe '#options_admin' do
14
- context 'For admin request' do
15
- it do
16
- expect(rabbit.options_admin('admin::sessions')).to \
17
- match_json_schema(:rabbit_options_admin)
18
- end
19
- end
20
-
21
- context 'For base request' do
22
- it do
23
- expect(rabbit.options_admin('request::create')).to \
24
- match_json_schema(:rabbit_options)
25
- end
26
- end
27
- end
28
- end
29
5
  describe RubyRabbitmqJanus::Rabbit::Propertie, type: :rabbit,
30
6
  name: :propertie,
31
7
  instances: true do
@@ -3,6 +3,8 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe RubyRabbitmqJanus::Janus::Responses::Admin, type: :responses,
6
+ level: :admin,
7
+ broken: true,
6
8
  name: :admin do
7
9
  let(:message) do
8
10
  @gateway.start_transaction_admin do |transaction|
@@ -3,20 +3,37 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe RubyRabbitmqJanus::Tools::Cluster, type: :tools, name: :cluster do
6
+ let(:cluster) { RubyRabbitmqJanus::Tools::Cluster.instance }
7
+ let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
8
+ let(:number_of_instance) { Random.new.rand(100) }
9
+ let(:name_queue) { "to-janus-#{number_of_instance}" }
10
+ let(:name_queue_admin) { "to-janus-admin-#{number_of_instance}" }
11
+
12
+ it do
13
+ expect(cluster.queue_to(number_of_instance)).to eql(name_queue)
14
+ end
15
+
6
16
  it do
7
- expect(RubyRabbitmqJanus::Tools::Cluster.instance.queue_to(42)).to \
8
- eql('to-janus-42')
17
+ expect(cluster.queue_admin_to(number_of_instance)).to eql(name_queue_admin)
9
18
  end
10
19
 
11
20
  it do
12
- expect(RubyRabbitmqJanus::Tools::Cluster.instance.queue_admin_to(42)).to \
13
- eql('to-janus-admin-42')
21
+ expect { cluster.create_session }.not_to raise_error
22
+ end
23
+
24
+ it do
25
+ expect { cluster.restart_session }.not_to raise_error
26
+ end
27
+
28
+ context 'When active record is loaded', orm: :active_record do
29
+ it do
30
+ expect(cluster.create_session).to be_a(model)
31
+ end
14
32
  end
15
33
 
16
- context 'when created sessions with active record' do
34
+ context 'When mongoid is loaded', orm: :mongoid do
17
35
  it do
18
- expect(RubyRabbitmqJanus::Tools::Cluster.instance.create_session).to \
19
- be_a(Integer)
36
+ expect(cluster.create_session).to be_a(model)
20
37
  end
21
38
  end
22
39
  end
@@ -3,53 +3,81 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::Log', type: :tools, name: :log do
6
+ let(:levels) {
7
+ {
8
+ DEBUG: Logger::DEBUG,
9
+ INFO: Logger::INFO,
10
+ WARN: Logger::WARN,
11
+ ERROR: Logger::ERROR,
12
+ FATAL: Logger::FATAL,
13
+ UNKNOWN: Logger::UNKNOWN
14
+ }
15
+ }
16
+ let(:sensitives) { %i[admin_secret apisecret] }
17
+ let(:log) { RubyRabbitmqJanus::Tools::Log.instance }
18
+ let(:log_constant) { RubyRabbitmqJanus::Tools::Log }
19
+ let(:new_level) { Random.new.rand(5) }
20
+ let(:message) { '## test ##' }
21
+ let(:last_line) { IO.readlines('log/ruby-rabbitmq-janus.log')[-1..-1][0] }
22
+
23
+ it 'Default levels' do
24
+ expect(log_constant::LEVELS).to eql(levels)
25
+ end
26
+
27
+ it 'Defaults sensitives word' do
28
+ expect(log_constant::SENSITIVES).to eql(sensitives)
29
+ end
30
+
6
31
  it 'Log instance is correctly loading' do
7
- expect(RubyRabbitmqJanus::Tools::Log.instance).not_to be(nil)
32
+ expect(log).not_to be(nil)
8
33
  end
9
34
 
10
35
  it 'Default level log is INFO' do
11
36
  # 0 = debug
12
37
  # ...
13
38
  # 5 = unknown
14
- expect(RubyRabbitmqJanus::Tools::Log.instance.level).to eq(0)
39
+ expect(log.level).to eq(0)
15
40
  end
16
41
 
17
- let(:message) { '## test ##' }
18
- let(:last_line) { IO.readlines('log/ruby-rabbitmq-janus.log')[-1..-1][0] }
19
-
20
42
  context 'when write a message unknown' do
21
- before { RubyRabbitmqJanus::Tools::Log.instance.unknown(message) }
43
+ before { log.unknown(message) }
22
44
 
23
45
  it { expect(last_line).to include('A, [RubyRabbitmqJanus] ## test ##') }
24
46
  end
25
47
 
26
48
  context 'when write a message fatal' do
27
- before { RubyRabbitmqJanus::Tools::Log.instance.fatal(message) }
49
+ before { log.fatal(message) }
28
50
 
29
51
  it { expect(last_line).to include('F, [RubyRabbitmqJanus] ## test ##') }
30
52
  end
31
53
 
32
54
  context 'when write a message error' do
33
- before { RubyRabbitmqJanus::Tools::Log.instance.error(message) }
55
+ before { log.error(message) }
34
56
 
35
57
  it { expect(last_line).to include('E, [RubyRabbitmqJanus] ## test ##') }
36
58
  end
37
59
 
38
60
  context 'when write a message warn' do
39
- before { RubyRabbitmqJanus::Tools::Log.instance.warn(message) }
61
+ before { log.warn(message) }
40
62
 
41
63
  it { expect(last_line).to include('W, [RubyRabbitmqJanus] ## test ##') }
42
64
  end
43
65
 
44
66
  context 'when write a message info' do
45
- before { RubyRabbitmqJanus::Tools::Log.instance.info(message) }
67
+ before { log.info(message) }
46
68
 
47
69
  it { expect(last_line).to include('I, [RubyRabbitmqJanus] ## test ##') }
48
70
  end
49
71
 
50
72
  context 'when write a message debug' do
51
- before { RubyRabbitmqJanus::Tools::Log.instance.debug(message) }
73
+ before { log.debug(message) }
52
74
 
53
75
  it { expect(last_line).to include('D, [RubyRabbitmqJanus] ## test ##') }
54
76
  end
77
+
78
+ context 'Whane level is changed' do
79
+ it 'Change level' do
80
+ expect(log.save_level(new_level)).to eql(log.level)
81
+ end
82
+ end
55
83
  end
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,14 @@ require 'bundler/setup'
4
4
  require 'pry'
5
5
  require 'json-schema-rspec'
6
6
  require 'rails'
7
- require 'active_record'
7
+ require 'database_cleaner'
8
+ ENV['MONGO']='true' if ENV['MONGO'].nil?
9
+ require ENV['MONGO'].match?('true') ? 'mongoid' : 'active_record'
10
+
8
11
  require 'ruby_rabbitmq_janus'
12
+ require 'config/initializer'
13
+ require 'config/database'
14
+ require 'config/instance'
9
15
 
10
16
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
11
17
 
@@ -18,24 +24,9 @@ end
18
24
  end
19
25
 
20
26
  RSpec.configure do |config|
21
- # Configure active record
22
- # rubocop:disable Style/ColonMethodCall
23
- # rubocop:disable Security/YAMLLoad
24
- configuration = YAML::load(File.open('config/database.yml'))
25
- # rubocop:enable Style/ColonMethodCall
26
- # rubocop:enable Security/YAMLLoad
27
-
28
- # Connect to database
29
- ActiveRecord::Base.establish_connection(configuration)
30
- config.before(:all) do
31
- unless ActiveRecord::Base.connection.table_exists? 'janus_instances'
32
- ActiveRecord::Base.connection.create_table(:janus_instances) do |table|
33
- table.integer :instance
34
- table.integer :session, limit: 8
35
- table.boolean :enable
36
- end
37
- end
38
- end
27
+ DatabaseCleaner.strategy = :truncation
28
+ ENV['MONGO'].match?('true') ? load_mongo : load_active_record
29
+ after_load_database
39
30
 
40
31
  config.expect_with :rspec do |c|
41
32
  c.syntax = :expect
@@ -59,65 +50,21 @@ RSpec.configure do |config|
59
50
  config.json_schemas[json_index] = json_file
60
51
  end
61
52
 
62
- # Configure requests test before sending request
63
- config.before(:example, level: :base) { gateway }
64
- config.before(:example, level: :peer) { gateway }
65
- config.before(:example, level: :admin) { gateway_admin }
66
- config.before(:example, type: :responses) { gateway }
67
- config.before(:example, type: :messages) { gateway }
68
- config.before(:example, name: :admin) { gateway_admin }
69
- config.before(:example, name: :event) { gateway }
70
- config.before(:example, name: :standard) { gateway }
71
-
72
53
  # Exclude request with tag broken
73
54
  config.filter_run_excluding broken: true
74
- end
75
-
76
- # :reek:UtilityFunction
77
- def singleton
78
- Singleton.__init__(RubyRabbitmqJanus::Tools::Log)
79
- Singleton.__init__(RubyRabbitmqJanus::Tools::Config)
80
- Singleton.__init__(RubyRabbitmqJanus::Tools::Requests)
81
- Singleton.__init__(RubyRabbitmqJanus::Tools::Cluster)
82
- end
83
-
84
- def gateway
85
- singleton
86
- @gateway = RubyRabbitmqJanus::RRJ.new
87
- @response = nil
88
- @options = {}
89
- find_instance
90
- end
91
-
92
- def gateway_admin
93
- singleton
94
- @gateway = RubyRabbitmqJanus::RRJAdmin.new
95
- @response = nil
96
- @options = {}
97
- find_instance
98
- end
99
-
100
- def gateway_event
101
- actions = EventTest.new.actions
102
- @event = RubyRabbitmq::Janus::Concurencies::Event.instance
103
- @event.run(&actions)
104
- gateway
105
- find_instance
106
- end
107
-
108
- def find_instance
109
- ji = RubyRabbitmqJanus::Models::JanusInstance.first
110
- @session = { 'session_id' => ji.session }
111
- @instance = { 'instance' => ji.instance }
112
- @session_instance = @session.merge(@instance)
113
- end
114
55
 
115
- # Test events response
116
- class EventTest
117
- def actions
118
- lambda do |reason, payload|
119
- p "Reason : #{reason}"
120
- p "Payload : #{payload}"
121
- end
56
+ config.before(:example) do |example|
57
+ @gateway = if example.metadata[:level]
58
+ RubyRabbitmqJanus::RRJAdmin.new
59
+ else
60
+ RubyRabbitmqJanus::RRJ.new
61
+ end
62
+
63
+ ji = RubyRabbitmqJanus::Models::JanusInstance.first
64
+ @response = nil
65
+ @options = {}
66
+ @session = { 'session_id' => ji.session }
67
+ @instance = { 'instance' => ji.instance }
68
+ @session_instance = @session.merge(@instance)
122
69
  end
123
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.pre.42
4
+ version: 2.2.0.pre.159
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: '5.2'
265
+ - !ruby/object:Gem::Dependency
266
+ name: database_cleaner
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '1.6'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '1.6'
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: bunny
267
281
  requirement: !ruby/object:Gem::Requirement
@@ -472,6 +486,11 @@ files:
472
486
  - lib/tasks/delete_all_instance.rake
473
487
  - lib/tasks/delete_one_instance.rake
474
488
  - lib/tasks/delete_unless_instance.rake
489
+ - spec/config/database.rb
490
+ - spec/config/database.yml
491
+ - spec/config/initializer.rb
492
+ - spec/config/instance.rb
493
+ - spec/config/mongoid.yml
475
494
  - spec/request/admin/request_handle_info_spec.rb
476
495
  - spec/request/admin/request_handles_spec.rb
477
496
  - spec/request/admin/request_sessions_spec.rb
@@ -490,9 +509,9 @@ files:
490
509
  - spec/rrj/messages/messages_admin_spec.rb
491
510
  - spec/rrj/messages/messages_message_spec.rb
492
511
  - spec/rrj/messages/messages_standard_spec.rb
493
- - spec/rrj/models/active_record_spec.rb
494
- - spec/rrj/models/mongoid_spec.rb
512
+ - spec/rrj/models/janus_instance.rb
495
513
  - spec/rrj/rabbit/connect_spec.rb
514
+ - spec/rrj/rabbit/propertie_2_spec.rb
496
515
  - spec/rrj/rabbit/propertie_spec.rb
497
516
  - spec/rrj/rabbit/publish/admin_spec.rb
498
517
  - spec/rrj/rabbit/publish/base_publisher_spec.rb
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Style/ConstantName
4
-
5
- require 'spec_helper'
6
-
7
- describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
8
- name: :janus_instance do
9
- before do
10
- ActiveRecord::Core = nil if defined?(ActiveRecord)
11
- require 'mongoid' unless defined?(Mongoid)
12
- end
13
-
14
- context 'mongoid model' do
15
- let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
16
-
17
- it { expect(model.attribute_names).to include('id') }
18
- it { expect(model.attribute_names).to include('instance') }
19
- it { expect(model.attribute_names).to include('session') }
20
- it { expect(model.attribute_names).to include('enable') }
21
- end
22
-
23
- after do
24
- Object.send(:remove_const, :Mongoid) if defined?(Mongoid)
25
- require 'active_record' unless defined?(ActiveRecord)
26
- end
27
- end
28
- # rubocop:enable Style/ConstantName