Sha256: f35af031a462e452d524d0fe191519a8373d7c774cb8531aed6c94043ae899a5
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require 'spec_helper' describe "camel caser middleware for Rails", type: :rails do let(:json_object) do { userName: 'dsci', bar: { lordFoo: 12 }, "DE" => 'german' } end let(:json) { JSON.generate(json_object) } context "camel caser middleware for Rails with accept header " do before do Sparrow.configure do |config| config.allowed_accepts = %w[foo/bar] end end after do Sparrow.configure do |config| config.allowed_accepts = [nil] end end it 'does not process the request if the accept header is not allowed' do post '/posts', json, { 'request-json-format' => 'underscore', 'response-json-format' => 'underscore', 'CONTENT-TYPE' => 'application/json', 'ACCEPT' => 'text/html' } last_json = JSON.parse(last_response.body) expect(last_json['keys']).to include('userName') expect(last_json['keys']).to include('bar') expect(last_json['keys']).to include('DE') end it 'does process the request if the accept header is allowed' do post '/posts', json, { 'request-json-format' => 'underscore', 'response-json-format' => 'underscore', 'CONTENT-TYPE' => 'application/json', 'ACCEPT' => 'foo/bar, gate/protect' } last_json = JSON.parse(last_response.body) expect(last_json['keys']).to include('user_name') expect(last_json['keys']).to include('de') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cp-sparrow-0.0.16 | spec/integration/rails/camel_caser_accept_header_spec.rb |
cp-sparrow-0.0.15 | spec/integration/rails/camel_caser_accept_header_spec.rb |