Sha256: 11dd9ef36e8f2e16c72ae0fc8d39b634b335b2f9758d55087f462543a3682201

Contents?: true

Size: 800 Bytes

Versions: 66

Compression:

Stored size: 800 Bytes

Contents

module RSpec
  module ProtocolHelper
    SUPPORTED_PROTOCOLS = {
      json:    'JSON',
      msgpack: 'MsgPack'
    }

    PROTOCOLS = if ENV['PROTOCOL']
      protocol = ENV['PROTOCOL'].downcase.to_sym
      { protocol => SUPPORTED_PROTOCOLS[protocol] }
    else
      SUPPORTED_PROTOCOLS
    end

    def vary_by_protocol(&block)
      RSpec::ProtocolHelper::PROTOCOLS.each do |protocol, description|
        context("using #{description} protocol", protocol: protocol, &block)
      end
    end
  end
end

RSpec.configure do |config|
  config.extend RSpec::ProtocolHelper

  config.before(:context, protocol: :json) do |context|
    context.class.let(:protocol) { :json }
  end

  config.before(:context, protocol: :msgpack) do |context|
    context.class.let(:protocol) { :msgpack }
  end
end


Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.7 spec/support/protocol_helper.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.6 spec/support/protocol_helper.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.4 spec/support/protocol_helper.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.3 spec/support/protocol_helper.rb
ably-rest-1.2.2 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.2 spec/support/protocol_helper.rb
ably-rest-1.2.1 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.1 spec/support/protocol_helper.rb
ably-rest-1.2.0 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.2.0 spec/support/protocol_helper.rb
ably-rest-1.1.8 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.1.8 spec/support/protocol_helper.rb
ably-rest-1.1.7 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.1.7 spec/support/protocol_helper.rb
ably-rest-1.1.6 lib/submodules/ably-ruby/spec/support/protocol_helper.rb
ably-1.1.6 spec/support/protocol_helper.rb