Skip to content

Commit

Permalink
uses stub_const rather than polluting the global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
myxoh committed Nov 27, 2018
1 parent b52a861 commit 2891453
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spec/grape/named_api_spec.rb
@@ -1,13 +1,17 @@
require 'spec_helper'

describe 'A named API' do
NamedAPI = Class.new(Grape::API) do
get 'test' do
'response'
subject(:api_name) { NamedAPI.endpoints.last.options[:for].to_s }

let(:api) do
Class.new(Grape::API) do
get 'test' do
'response'
end
end
end

subject(:api_name) { NamedAPI.endpoints.last.options[:for].to_s }
before { stub_const('NamedAPI', api) }

it 'can access the name of the API' do
expect(api_name).to eq 'NamedAPI'
Expand Down

0 comments on commit 2891453

Please sign in to comment.