Sha256: 9b7d7655ef1dbb01ae99789352d367052c32ccf46c72a366f160d291a9d942a3

Contents?: true

Size: 1.08 KB

Versions: 36

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

RSpec.describe HTTP::Options, "features" do
  let(:opts) { HTTP::Options.new }

  it "defaults to be empty" do
    expect(opts.features).to be_empty
  end

  it "accepts plain symbols in array" do
    opts2 = opts.with_features([:auto_inflate])
    expect(opts.features).to be_empty
    expect(opts2.features.keys).to eq([:auto_inflate])
    expect(opts2.features[:auto_inflate]).
      to be_instance_of(HTTP::Features::AutoInflate)
  end

  it "accepts feature name with its options in array" do
    opts2 = opts.with_features([{:auto_deflate => {:method => :deflate}}])
    expect(opts.features).to be_empty
    expect(opts2.features.keys).to eq([:auto_deflate])
    expect(opts2.features[:auto_deflate]).
      to be_instance_of(HTTP::Features::AutoDeflate)
    expect(opts2.features[:auto_deflate].method).to eq("deflate")
  end

  it "raises error for not supported features" do
    expect { opts.with_features([:wrong_feature]) }.
      to raise_error(HTTP::Error) { |error|
        expect(error.message).to eq("Unsupported feature: wrong_feature")
      }
  end
end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/http-5.2.0/spec/lib/http/options/features_spec.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
http-5.2.0 spec/lib/http/options/features_spec.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/options/features_spec.rb
http-5.1.1 spec/lib/http/options/features_spec.rb
http-5.1.0 spec/lib/http/options/features_spec.rb
http-5.0.4 spec/lib/http/options/features_spec.rb
http-5.0.3 spec/lib/http/options/features_spec.rb
http-5.0.2 spec/lib/http/options/features_spec.rb
http-5.0.1 spec/lib/http/options/features_spec.rb
http-5.0.0 spec/lib/http/options/features_spec.rb
http-4.4.1 spec/lib/http/options/features_spec.rb
http-4.4.0 spec/lib/http/options/features_spec.rb
http-5.0.0.pre3 spec/lib/http/options/features_spec.rb
http-5.0.0.pre2 spec/lib/http/options/features_spec.rb
http-4.3.0 spec/lib/http/options/features_spec.rb