Sha256: bc590083c37741ca06c356864a677c359fe1658b5234144e0288ab64d8044555

Contents?: true

Size: 744 Bytes

Versions: 9

Compression:

Stored size: 744 Bytes

Contents

require 'spec_helper'

module Grape
  module DSL
    module MiddlewareSpec
      class Dummy
        include Grape::DSL::Middleware
      end
    end
    describe Middleware do
      subject { Class.new(MiddlewareSpec::Dummy) }
      let(:proc) { ->() {} }

      describe '.use' do
        it 'adds a middleware' do
          expect(subject).to receive(:namespace_stackable).with(:middleware, [:my_middleware, :arg1, proc])

          subject.use :my_middleware, :arg1, &proc
        end
      end

      describe '.middleware' do
        it 'returns the middleware stack' do
          subject.use :my_middleware, :arg1, &proc

          expect(subject.middleware).to eq [[:my_middleware, :arg1, proc]]
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
grape-0.16.2 spec/grape/dsl/middleware_spec.rb
grape-0.16.1 spec/grape/dsl/middleware_spec.rb
grape-0.15.0 spec/grape/dsl/middleware_spec.rb
grape-0.14.0 spec/grape/dsl/middleware_spec.rb
grape-0.13.0 spec/grape/dsl/middleware_spec.rb
grape-0.12.0 spec/grape/dsl/middleware_spec.rb
grape-0.11.0 spec/grape/dsl/middleware_spec.rb
grape-0.10.1 spec/grape/dsl/middleware_spec.rb
grape-0.10.0 spec/grape/dsl/middleware_spec.rb