Sha256: 274e023376fbf8bf38f44652d1b8f1a201d33968f93c398777165cc6c98c6181

Contents?: true

Size: 1.28 KB

Versions: 26

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

# :reek:UtilityFunction

module RubyRabbitmqJanus
  module Janus
    module Responses
      # Response for RSpec initializer
      class RSpec
        def initialize(type)
          path = RubyRabbitmqJanus::Tools::Config.instance.rspec_response
          @json = File.join(Dir.pwd,
                            path,
                            "#{type.gsub('::', '_')}.json")
        end

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

        def session
          (rand * 1_000_000).to_i
        end

        def plugin
          read['plugindata']
        end

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

        def data
          read['data']
        end

        def sdp
          read['jsep']
        end

        def sessions
          read['sessions']
        end

        def info
          read['info']
        end

        def keys
          [546_321_963, 546_321_966]
        end

        def instance
          JanusInstance.first
        end

        def enable
          [True, False].sample
        end

        alias id            session
        alias session_id    session
        alias sender        session
        alias handles       sessions
        alias jsep          sdp
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.7.2.pre.320 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.319 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.318 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.317 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.316 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.315 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.314 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.312 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.310 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.309 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.308 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.307 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.306 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.305 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.302 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.297 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.296 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.286 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.285 lib/rrj/janus/responses/rspec.rb
ruby_rabbitmq_janus-2.7.2.pre.284 lib/rrj/janus/responses/rspec.rb