2017-03-08 16:32:31 +08:00
|
|
|
# frozen_string_literal: true
|
2017-03-28 17:15:33 +08:00
|
|
|
|
2016-09-19 23:53:22 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe 'definition names' do
|
|
|
|
|
before :all do
|
|
|
|
|
module TestDefinition
|
|
|
|
|
module DummyEntities
|
|
|
|
|
module WithVeryLongName
|
|
|
|
|
module AnotherGroupingModule
|
|
|
|
|
class Class1
|
|
|
|
|
class Entity < Grape::Entity
|
2016-10-13 06:07:45 +08:00
|
|
|
expose :first_thing
|
2016-09-19 23:53:22 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class Class2
|
2016-10-13 05:31:19 +08:00
|
|
|
class Entities < Grape::Entity
|
2016-10-13 06:07:45 +08:00
|
|
|
expose :second_thing
|
2016-10-13 05:31:19 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class Class3
|
2016-09-19 23:53:22 +08:00
|
|
|
class Entity < Grape::Entity
|
2016-10-13 06:07:45 +08:00
|
|
|
expose :third_thing
|
2016-09-19 23:53:22 +08:00
|
|
|
|
|
|
|
|
def self.entity_name
|
|
|
|
|
'FooKlass'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-10-13 05:31:19 +08:00
|
|
|
|
|
|
|
|
class Class4
|
|
|
|
|
class FourthEntity < Grape::Entity
|
2016-10-13 06:07:45 +08:00
|
|
|
expose :fourth_thing
|
2016-10-13 05:31:19 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class Class5
|
|
|
|
|
class FithEntity < Class4::FourthEntity
|
2016-10-13 06:07:45 +08:00
|
|
|
expose :fith_thing
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class Class6
|
|
|
|
|
class SixthEntity < Grape::Entity
|
|
|
|
|
expose :sixth_thing
|
|
|
|
|
|
|
|
|
|
def self.entity_name
|
|
|
|
|
'BarKlass'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class Class7
|
|
|
|
|
class SeventhEntity < Class6::SixthEntity
|
|
|
|
|
expose :seventh_thing
|
2016-10-13 05:31:19 +08:00
|
|
|
end
|
|
|
|
|
end
|
2016-09-19 23:53:22 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class NameApi < Grape::API
|
|
|
|
|
add_swagger_documentation models: [
|
|
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class1::Entity,
|
2016-10-13 05:31:19 +08:00
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class2::Entities,
|
|
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class3::Entity,
|
|
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class4::FourthEntity,
|
2016-10-13 06:07:45 +08:00
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class5::FithEntity,
|
|
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class6::SixthEntity,
|
|
|
|
|
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class7::SeventhEntity
|
2016-09-19 23:53:22 +08:00
|
|
|
]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:app) { TestDefinition::NameApi }
|
|
|
|
|
|
|
|
|
|
subject do
|
|
|
|
|
get '/swagger_doc'
|
|
|
|
|
JSON.parse(last_response.body)['definitions']
|
|
|
|
|
end
|
|
|
|
|
|
2016-10-13 05:31:19 +08:00
|
|
|
specify { expect(subject).to include 'Class1' }
|
|
|
|
|
specify { expect(subject).to include 'Class2' }
|
2016-09-19 23:53:22 +08:00
|
|
|
specify { expect(subject).to include 'FooKlass' }
|
2016-10-13 05:31:19 +08:00
|
|
|
specify { expect(subject).to include 'FourthEntity' }
|
|
|
|
|
specify { expect(subject).to include 'FithEntity' }
|
2016-10-13 06:07:45 +08:00
|
|
|
specify { expect(subject).to include 'BarKlass' }
|
|
|
|
|
specify { expect(subject).to include 'SeventhEntity' }
|
2016-09-19 23:53:22 +08:00
|
|
|
end
|