Sha256: 4648f779d1ef81e237bd203b1fbe6cdbd045ec96a004d0f3d1185115b63d7472

Contents?: true

Size: 780 Bytes

Versions: 6

Compression:

Stored size: 780 Bytes

Contents

require File.expand_path('../helper', __FILE__)

class EncodingTest < Test::Unit::TestCase
  E = Rack::Accept::Encoding

  def test_qvalue
    e = E.new('')
    assert_equal(0, e.qvalue('gzip'))
    assert_equal(1, e.qvalue('identity'))

    e = E.new('gzip, *;q=0.5')
    assert_equal(1, e.qvalue('gzip'))
    assert_equal(0.5, e.qvalue('identity'))
  end

  def test_matches
    e = E.new('gzip, identity, *')
    assert_equal(%w{*}, e.matches(''))
    assert_equal(%w{gzip *}, e.matches('gzip'))
    assert_equal(%w{*}, e.matches('compress'))
  end

  def test_best_of
    e = E.new('gzip, compress')
    assert_equal('gzip', e.best_of(%w< gzip compress >))
    assert_equal('identity', e.best_of(%w< identity compress >))
    assert_equal(nil, e.best_of(%w< zip >))
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rack-accept-0.4.5/test/encoding_test.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rack-accept-0.4.5/test/encoding_test.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rack-accept-0.4.5/test/encoding_test.rb
rack-accept-0.4.5 test/encoding_test.rb
rack-accept-0.4.4 test/encoding_test.rb
rack-accept-0.4.3 test/encoding_test.rb