Sha256: 320aac11ac8c6a7532e74449e502314070bf9573b6b43e66d03e383f88975c7b
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' require 'rack/test' require 'grape-entity' require 'grape/msgpack' class MockModel def initialize(name, age) @name = name @age = age end attr_reader :name, :age end class MockEntity < Grape::Entity expose :name end class MockAPI < Grape::API default_format :msgpack get :test do [1, 2, 3] end get :model do present MockModel.new('test_user', 21), with: MockEntity end end describe MockAPI do include Rack::Test::Methods def app MockAPI end describe 'GET /test' do subject(:response) do get '/test' last_response end it { expect(response.status).to eq(200) } it { expect(response.headers["Content-Type"]).to eq('application/x-msgpack') } it { expect(MessagePack.unpack(response.body)).to eq([1, 2, 3]) } end describe 'GET /model' do subject(:response) do get '/model' last_response end it { expect(response.status).to eq(200) } it { expect(response.headers["Content-Type"]).to eq('application/x-msgpack') } it { expect(MessagePack.unpack(response.body)).to eq("name" => "test_user") } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-msgpack-0.0.1 | spec/grape/msgpack_spec.rb |