Sha256: a9dc3e1b7098b0067275352b6a11a21eff0667206585f0ef09928b0b21de950d

Contents?: true

Size: 877 Bytes

Versions: 7

Compression:

Stored size: 877 Bytes

Contents

require 'spec_helper'

describe 'Grape::EndpointExtension' do
  if Grape::Util.const_defined?('InheritableSetting')
    subject { Grape::Endpoint.new(Grape::Util::InheritableSetting.new, path: '/', method: 'foo') }
  else
    subject { Grape::Endpoint.new({}, path: '/', method: 'foo') }
  end

  let(:serializer) { Grape::Formatter::JSONAPIResources }

  let(:user) do
    User.new(name: "yasiel")
  end

  let(:users) { [user, user] }

  describe '#render' do
    before do
      allow(subject).to receive(:env).and_return({})
    end

    it { should respond_to(:render) }

    context 'settings options' do
      it 'sets the jsonapi options on the environment' do
        expect(subject.render(users, {include: ["included_resource"]})).to eq(users)
        expect(subject.env).to include({"jsonapi_options"=>{:include=>["included_resource"]}})
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
grape-jsonapi-resources-0.0.7 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.6 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.5 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.4 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.3 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.2 spec/grape-jsonapi-resources/endpoint_extension_spec.rb
grape-jsonapi-resources-0.0.1 spec/grape-jsonapi-resources/endpoint_extension_spec.rb