summaryrefslogtreecommitdiff
path: root/spec/unit/request/parameter/custom_spec.rb
blob: 1abebc94eadec2df7eb26da1ef3c563996b7674e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'spec_helper'

describe Zero::Request::Parameter, '#custom' do
  subject { Zero::Request::Parameter.new(env) }
  let(:env) { EnvGenerator.get('/foo') }

  it 'returns a set custom parameter' do
    subject['foo'] = 'bar'
    expect(subject.custom['foo']).to eq('bar')
  end

  it 'returns the latest set value' do
    subject['foo'] = 'first'
    subject['foo'] = 'latest'

    expect(subject.custom['foo']).to eq('latest')
  end

  it 'is empty if no custom parameter is set' do
    expect(subject.custom).to eq({})
    expect(env['zero.params.custom']).to eq({})
  end
end