spec/grape/reload/rack_builder_spec.rb in grape-reload-0.0.3 vs spec/grape/reload/rack_builder_spec.rb in grape-reload-0.0.4

- old
+ new

@@ -9,11 +9,22 @@ config end end end } + let(:middleware) { + Class.new do + def initialize(app) + @app = app + end + def call(env) + @app.call(env) + end + end + } + before do builder.setup do environment 'development' add_source_path File.expand_path('**/*.rb', APP_ROOT) end @@ -35,12 +46,20 @@ mount 'TestClass1', to: '/test1' mount 'TestClass2', to: '/test2' end expect(config.mounts.size).to eq(2) end + + it 'allows to add middleware' do + builder.setup do + use middleware do + end + end + expect(config.middleware.size).to eq(1) + end end - # + describe '.boot!' do before(:each) do builder.setup do mount 'Test::App1', to: '/test1' mount 'Test::App2', to: '/test2' @@ -61,18 +80,21 @@ end describe '.application' do before(:each) do builder.setup do + use middleware mount 'Test::App1', to: '/test1' mount 'Test::App2', to: '/test2' end builder.boot! end it 'creates Rack::Builder application' do expect{ @app = builder.application }.not_to raise_error expect(@app).to be_an_instance_of(Rack::Builder) def @app.get_map; @map end + def @app.get_use; @use end + expect(@app.get_use.size).to eq(1) expect(@app.get_map.keys).to include('/test1','/test2') end end end \ No newline at end of file