Sha256: c29b5967198a340ffd2435975b898df8b125b5819b7d9aa15b85bf7e84e1fb94

Contents?: true

Size: 858 Bytes

Versions: 19

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

require 'rack/utils'

RSpec.describe Faraday::FlatParamsEncoder do
  it_behaves_like 'a params encoder'

  it 'decodes arrays' do
    query = 'a=one&a=two&a=three'
    expected = { 'a' => %w[one two three] }
    expect(subject.decode(query)).to eq(expected)
  end

  it 'decodes boolean values' do
    query = 'a=true&b=false'
    expected = { 'a' => 'true', 'b' => 'false' }
    expect(subject.decode(query)).to eq(expected)
  end

  it 'encodes boolean values' do
    params = { a: true, b: false }
    expect(subject.encode(params)).to eq('a=true&b=false')
  end

  it 'encodes boolean values in array' do
    params = { a: [true, false] }
    expect(subject.encode(params)).to eq('a=true&a=false')
  end

  it 'encodes empty array in hash' do
    params = { a: [] }
    expect(subject.encode(params)).to eq('a=')
  end
end

Version data entries

19 entries across 18 versions & 8 rubygems

Version Path
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/spec/faraday/params_encoders/flat_spec.rb
faraday-1.0.1 spec/faraday/params_encoders/flat_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.0/spec/faraday/params_encoders/flat_spec.rb
faraday-1.0.0 spec/faraday/params_encoders/flat_spec.rb