Sha256: f8360603fbd212bf8df6d5654f4bdbab0e9e09bc1a10be7cbfdc7ec56ad9e872
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe "camel caser middleware", type: :rack do let(:json) do JSON.generate({userName: "dsci", bar:{ lordFoo: 12 }}) end context "accept header is given" do before do post '/', json, {'request-json-format' => 'underscore', 'response-json-format' => 'underscore'} end subject do JSON.parse(last_response.body) end it "converts lower camelcase to underscore params" do expect(subject).to have_key("keys") expect(subject["keys"]).to include("user_name") expect(subject["keys"]).to include("bar") expect(subject["keys"]).to include("lord_foo") expect(subject).to have_key 'fake_key' end end context "default behavior without manual configuration" do before do post '/', json end subject do JSON.parse(last_response.body) end it "converts incoming camelCase arguments to snake_case" do expect(subject).to have_key("keys") expect(subject["keys"]).to include("user_name") end it 'converted the snake case fake key to camelCase for the response' do expect(subject['fake_key']).to_not be_present expect(subject['fakeKey']).to eq false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cp-sparrow-0.0.16 | spec/integration/rack/camel_caser_spec.rb |
cp-sparrow-0.0.15 | spec/integration/rack/camel_caser_spec.rb |