Sha256: faadba36f65935b5e15d26ef4092dd73d442814b0310fbac63c50d90e25fad6b

Contents?: true

Size: 1.13 KB

Versions: 53

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

class TestMiddleware < Acfs::Middleware::Base
end

describe Acfs::Service::Middleware do
  let(:srv_class) { Class.new(Acfs::Service) }
  let(:options) { {} }
  let(:service) { srv_class.new options }
  let(:middleware) { TestMiddleware }

  describe '.use' do
    let(:options) { { abc: 'cde' } }

    it 'should add middleware to list' do
      srv_class.use middleware

      expect(srv_class.instance_variable_get(:@middlewares)).to include(middleware)
    end

    it 'should add middleware to stack' do
      srv_class.use middleware

      expect(srv_class.middleware).to be_a(middleware)
    end

    it 'should instantiate middleware object' do
      middleware.should_receive(:new).with(anything, options)

      srv_class.use middleware, options
    end
  end

  describe '.clear' do
    before { srv_class.use middleware }

    it 'should clear middleware list' do
      srv_class.clear

      expect(srv_class.instance_variable_get(:@middlewares)).to be_empty
    end

    it 'should reset middleware stack' do
      srv_class.clear

      expect(srv_class.instance_variable_get(:@middleware)).to be_nil
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
acfs-0.23.2 spec/acfs/service/middleware_spec.rb
acfs-0.23.1.b198 spec/acfs/service/middleware_spec.rb
acfs-0.23.1 spec/acfs/service/middleware_spec.rb
acfs-0.23.0.b197 spec/acfs/service/middleware_spec.rb
acfs-0.22.2.b196 spec/acfs/service/middleware_spec.rb
acfs-0.23.0 spec/acfs/service/middleware_spec.rb
acfs-0.22.2.b194 spec/acfs/service/middleware_spec.rb
acfs-0.22.2.b193 spec/acfs/service/middleware_spec.rb
acfs-0.22.2 spec/acfs/service/middleware_spec.rb
acfs-0.22.1.b192 spec/acfs/service/middleware_spec.rb
acfs-0.22.1 spec/acfs/service/middleware_spec.rb
acfs-0.22.0.b191 spec/acfs/service/middleware_spec.rb
acfs-0.22.0.b190 spec/acfs/service/middleware_spec.rb
acfs-0.22.0 spec/acfs/service/middleware_spec.rb
acfs-0.21.1.b189 spec/acfs/service/middleware_spec.rb
acfs-0.21.1.rc1.b188 spec/acfs/service/middleware_spec.rb
acfs-0.21.1 spec/acfs/service/middleware_spec.rb
acfs-0.21.0.rc1.b187 spec/acfs/service/middleware_spec.rb
acfs-0.21.1.rc1 spec/acfs/service/middleware_spec.rb
acfs-0.21.0.rc1 spec/acfs/service/middleware_spec.rb