spec/lib/oapi_tasks_spec.rb in grape-swagger-1.0.0 vs spec/lib/oapi_tasks_spec.rb in grape-swagger-1.1.0
- old
+ new
@@ -1,12 +1,12 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GrapeSwagger::Rake::OapiTasks do
- let(:api) do
- item = Class.new(Grape::API) do
+ module Api
+ class Item < Grape::API
version 'v1', using: :path
namespace :item do
get '/'
end
@@ -14,17 +14,27 @@
namespace :otherItem do
get '/'
end
end
- Class.new(Grape::API) do
+ class Base < Grape::API
prefix :api
- mount item
+ mount Api::Item
add_swagger_documentation add_version: true
end
end
- subject { described_class.new(api) }
+ subject { described_class.new(Api::Base) }
+
+ describe '.new' do
+ it 'accepts class name as a constant' do
+ expect(described_class.new(::Api::Base).send(:api_class)).to eq(Api::Base)
+ end
+
+ it 'accepts class name as a string' do
+ expect(described_class.new('::Api::Base').send(:api_class)).to eq(Api::Base)
+ end
+ end
describe '#make_request' do
describe 'complete documentation' do
before do
subject.send(:make_request)