spec/grape/reload/autoreload_interceptor_spec.rb in grape-reload-0.0.3 vs spec/grape/reload/autoreload_interceptor_spec.rb in grape-reload-0.0.4
- old
+ new
@@ -1,12 +1,14 @@
require 'spec_helper'
require_relative '../../../lib/grape/reload/grape_api'
describe Grape::Reload::AutoreloadInterceptor do
- let(:api_class) {
+ let!(:api_class) {
nested_class = Class.new(Grape::API) do
- get :route do
- 'nested route'
+ namespace :nested do
+ get :route do
+ 'nested route'
+ end
end
end
Class.new(Grape::API) do
format :txt
@@ -16,11 +18,11 @@
mount nested_class => '/nested'
end
}
describe '.reinit!' do
- let(:app) {
+ let!(:app) {
app = Rack::Builder.new
app.run api_class
app
}
it 'exists' do
@@ -29,12 +31,18 @@
it 'reinit Grape API declaration' do
get '/test_route'
expect(last_response).to succeed
expect(last_response.body).to eq('test')
+ get '/nested/nested/route'
+ expect(last_response).to succeed
+ expect(last_response.body).to eq('nested route')
api_class.reinit!
get '/test_route'
expect(last_response).to succeed
expect(last_response.body).to eq('test')
+ get '/nested/nested/route'
+ expect(last_response).to succeed
+ expect(last_response.body).to eq('nested route')
end
end
end
\ No newline at end of file