File: params_encoder.rb

package info (click to toggle)
ruby-faraday 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,008 kB
  • sloc: ruby: 6,509; sh: 10; makefile: 8
file content (18 lines) | stat: -rw-r--r-- 502 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

shared_examples 'a params encoder' do
  it 'escapes safe buffer' do
    monies = FakeSafeBuffer.new('$32,000.00')
    expect(subject.encode('a' => monies)).to eq('a=%2432%2C000.00')
  end

  it 'raises type error for empty string' do
    expect { subject.encode('') }.to raise_error(TypeError) do |error|
      expect(error.message).to eq("Can't convert String into Hash.")
    end
  end

  it 'encodes nil' do
    expect(subject.encode('a' => nil)).to eq('a')
  end
end