Sha256: 1fcec659796b949b448d3c1efa4360e1f381e54882474f225120eb5b53d81177
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'spec_helper' describe "camel caser middleware", type: :rack do let(:json) do MultiJson.dump({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 MultiJson.load(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 "accept header is not given" do before do post '/', json end subject do MultiJson.load(last_response.body) end it "did not convert lower camelcase to underscore params" do expect(subject).to have_key("keys") expect(subject["keys"]).to include("userName") end it 'converted the snake case fake key to camelCase' do expect(subject['fake_key']).to_not be_present expect(subject['fakeKey']).to eq true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cp-sparrow-0.0.12 | spec/integration/rack/camel_caser_spec.rb |
cp-sparrow-0.0.11 | spec/integration/rack/camel_caser_spec.rb |