class RubyRabbitmqJanus::Janus::Responses::RSpec

Response for RSpec initializer

Public Class Methods

new(type) click to toggle source

Constructor to RSpec response. Create a fake response for testing library.

# File lib/rrj/janus/responses/rspec.rb, line 12
def initialize(type)
  path = RubyRabbitmqJanus::Tools::Config.instance.rspec_response
  @json = File.join(Dir.pwd,
                    path,
                    "#{type.gsub('::', '_')}.json")
end

Public Instance Methods

data() click to toggle source

Read data dield

# File lib/rrj/janus/responses/rspec.rb, line 40
def data
  read['data']
end
enable() click to toggle source

Read fake status to instance

@return [Boolean] Random value

# File lib/rrj/janus/responses/rspec.rb, line 72
def enable
  [True, False].sample
end
handles()
Alias for: sessions
id()
Alias for: session
info() click to toggle source

Read info field

# File lib/rrj/janus/responses/rspec.rb, line 55
def info
  read['info']
end
instance() click to toggle source

Read first Janusinstance in database

# File lib/rrj/janus/responses/rspec.rb, line 65
def instance
  JanusInstance.first
end
jsep()
Alias for: sdp
keys() click to toggle source

Read fake keys

# File lib/rrj/janus/responses/rspec.rb, line 60
def keys
  [546_321_963, 546_321_966]
end
plugin() click to toggle source

Read plugindata field

# File lib/rrj/janus/responses/rspec.rb, line 30
def plugin
  read['plugindata']
end
plugin_data() click to toggle source

Read data to plugindata field

# File lib/rrj/janus/responses/rspec.rb, line 35
def plugin_data
  read['plugindata']['data']
end
read() click to toggle source

Read response json file

# File lib/rrj/janus/responses/rspec.rb, line 20
def read
  JSON.parse(File.read(@json))
end
sdp() click to toggle source

Read sdp

# File lib/rrj/janus/responses/rspec.rb, line 45
def sdp
  read['jsep']
end
Also aliased as: jsep
sender()
Alias for: session
session() click to toggle source

Create fake session number

# File lib/rrj/janus/responses/rspec.rb, line 25
def session
  (rand * 1_000_000).to_i
end
Also aliased as: id, session_id, sender
session_id()
Alias for: session
sessions() click to toggle source

Read sessions field

# File lib/rrj/janus/responses/rspec.rb, line 50
def sessions
  read['sessions']
end
Also aliased as: handles