0
0
zero/spec/unit/request/parameter/payload_spec.rb
Stormwind cd97198e22 Kill all mutants in Zero::Request::Parameter
I've also changed "extract_query_params" because it does not matter, if the
query string it empty or not for the "parse_string" method.
2013-01-06 10:28:13 +01:00

44 lines
1.1 KiB
Ruby

require 'spec_helper'
describe Zero::Request::Parameter, '#payload' do
subject { Zero::Request::Parameter.new(env) }
context 'without parameters' do
let(:env) { EnvGenerator.get('/foo') }
its(:payload) { should == {} }
end
context 'with a query string' do
let(:env) { EnvGenerator.get('/foo?bar=baz') }
its(:payload) { should == {} }
end
context 'with a post body' do
let(:env) do
EnvGenerator.post('/foo', {
:input => 'bar=baz', 'CONTENT_TYPE' => 'multipart/form-data'
})
end
its(:payload) { should == {'bar' => 'baz'} }
end
context 'with special characters' do
let(:env) do
EnvGenerator.post('/foo', {
:input => 'bar=foo%20bar', 'CONTENT_TYPE' => 'multipart/form-data'
})
end
its(:payload) { should == {'bar' => 'foo bar'} }
end
# TODO behaves like this, but is this really good like this?
context 'with a post body and content type application/json' do
let(:env) do
EnvGenerator.post('/foo', {
:input => '"foobar"', 'CONTENT_TYPE' => 'application/json'
})
end
its(:payload) { should == {} }
end
end