Class: RubyRabbitmqJanus::Janus::Responses::RSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/rrj/janus/responses/rspec.rb

Overview

Response for RSpec initializer

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ RSpec

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



12
13
14
15
16
17
# 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

Instance Method Details

#dataObject

Read data dield



40
41
42
# File 'lib/rrj/janus/responses/rspec.rb', line 40

def data
  read['data']
end

#enableBoolean

Read fake status to instance

Returns:

  • (Boolean)

    Random value



72
73
74
# File 'lib/rrj/janus/responses/rspec.rb', line 72

def enable
  [True, False].sample
end

#infoObject

Read info field



55
56
57
# File 'lib/rrj/janus/responses/rspec.rb', line 55

def info
  read['info']
end

#instanceObject

Read first Janusinstance in database



65
66
67
# File 'lib/rrj/janus/responses/rspec.rb', line 65

def instance
  JanusInstance.first
end

#keysObject

Read fake keys



60
61
62
# File 'lib/rrj/janus/responses/rspec.rb', line 60

def keys
  [546_321_963, 546_321_966]
end

#pluginObject

Read plugindata field



30
31
32
# File 'lib/rrj/janus/responses/rspec.rb', line 30

def plugin
  read['plugindata']
end

#plugin_dataObject

Read data to plugindata field



35
36
37
# File 'lib/rrj/janus/responses/rspec.rb', line 35

def plugin_data
  read['plugindata']['data']
end

#readObject

Read response json file



20
21
22
# File 'lib/rrj/janus/responses/rspec.rb', line 20

def read
  JSON.parse(File.read(@json))
end

#sdpObject Also known as: jsep

Read sdp



45
46
47
# File 'lib/rrj/janus/responses/rspec.rb', line 45

def sdp
  read['jsep']
end

#sessionObject Also known as: id, session_id, sender

Create fake session number



25
26
27
# File 'lib/rrj/janus/responses/rspec.rb', line 25

def session
  (rand * 1_000_000).to_i
end

#sessionsObject Also known as: handles

Read sessions field



50
51
52
# File 'lib/rrj/janus/responses/rspec.rb', line 50

def sessions
  read['sessions']
end