Sha256: 43d745194e28c74c23b22caf51b772f96ab5577acc5703bb5b4f41479cceffe5

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

require 'spec_helper'
require_relative '../../../lib/grape/reload/grape_api'
describe Grape::Reload::AutoreloadInterceptor do
  let(:api_class) {
    nested_class = Class.new(Grape::API) do
      get :route do
        'nested route'
      end
    end

    Class.new(Grape::API) do
      format :txt
      get :test_route do
        'test'
      end
      mount nested_class => '/nested'
    end
  }

  describe '.reinit!' do
    let(:app) {
      app = Rack::Builder.new
      app.run api_class
      app
    }
    it 'exists' do
      expect(api_class).to respond_to('reinit!')
    end

    it 'reinit Grape API declaration' do
      get '/test_route'
      expect(last_response).to succeed
      expect(last_response.body).to eq('test')
      api_class.reinit!
      get '/test_route'
      expect(last_response).to succeed
      expect(last_response.body).to eq('test')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-reload-0.0.3 spec/grape/reload/autoreload_interceptor_spec.rb
grape-reload-0.0.2 spec/grape/reload/autoreload_interceptor_spec.rb