Sha256: 9878c2c799a07afbdb53c1d3eda7725ffe3a1a9d307c64adb77e0a5a35c607b8

Contents?: true

Size: 608 Bytes

Versions: 3

Compression:

Stored size: 608 Bytes

Contents

require 'spec_helper'

describe Grape::Roar::Decorator do
  subject do
    Class.new(Grape::API)
  end

  before do
    subject.format :json
    subject.formatter :json, Grape::Formatter::Roar
  end

  def app
    subject
  end

  context 'decorator' do
    before do
      subject.get('/user/:id') do
        present User.new(name: 'Lonestar', id: params[:id]), with: UserRepresenter
      end
    end

    it 'returns a hypermedia representation' do
      get '/user/666'
      expect(last_response.body).to eq '{"name":"Lonestar","id":"666","links":[{"rel":"self","href":"/user/666"}]}'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-roar-0.4.0 spec/decorator_spec.rb
grape-roar-0.3.0 spec/decorator_spec.rb
grape-roar-0.2.0 spec/decorator_spec.rb