Sha256: 237d5204e8981e9a5c2dcc3c360f825d00418b1e005cd6e207a241ab126a0700

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module DeeplyIncludedOptionsSpec
  module Defaults
    extend ActiveSupport::Concern
    included do
      format :json
    end
  end

  module Admin
    module Defaults
      extend ActiveSupport::Concern
      include DeeplyIncludedOptionsSpec::Defaults
    end

    class Users < Grape::API
      include DeeplyIncludedOptionsSpec::Admin::Defaults

      resource :users do
        get do
          status 200
        end
      end
    end
  end

  class Main < Grape::API
    mount DeeplyIncludedOptionsSpec::Admin::Users
  end
end

describe Grape::API do
  subject { DeeplyIncludedOptionsSpec::Main }

  def app
    subject
  end

  it 'works for unspecified format' do
    get '/users'
    expect(last_response.status).to eql 200
    expect(last_response.content_type).to eql 'application/json'
  end

  it 'works for specified format' do
    get '/users.json'
    expect(last_response.status).to eql 200
    expect(last_response.content_type).to eql 'application/json'
  end

  it "doesn't work for format different than specified" do
    get '/users.txt'
    expect(last_response.status).to eql 404
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
grape-1.6.0 spec/grape/api/deeply_included_options_spec.rb
grape-1.5.3 spec/grape/api/deeply_included_options_spec.rb
grape-1.5.2 spec/grape/api/deeply_included_options_spec.rb
grape-1.5.1 spec/grape/api/deeply_included_options_spec.rb
grape-1.5.0 spec/grape/api/deeply_included_options_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/spec/grape/api/deeply_included_options_spec.rb
grape-1.4.0 spec/grape/api/deeply_included_options_spec.rb
grape-1.3.3 spec/grape/api/deeply_included_options_spec.rb
grape-1.3.2 spec/grape/api/deeply_included_options_spec.rb
grape-1.3.1 spec/grape/api/deeply_included_options_spec.rb
grape-1.3.0 spec/grape/api/deeply_included_options_spec.rb