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.25.0.1.b227 spec/acfs/service/middleware_spec.rb
acfs-0.25.0.1.b226 spec/acfs/service/middleware_spec.rb
acfs-0.25.0.1.b225 spec/acfs/service/middleware_spec.rb
acfs-0.25.0.1.b223 spec/acfs/service/middleware_spec.rb
acfs-0.25.0.1.b221 spec/acfs/service/middleware_spec.rb
acfs-0.25.0.1.b217 spec/acfs/service/middleware_spec.rb
acfs-0.25.0 spec/acfs/service/middleware_spec.rb
acfs-0.24.0.1.b216 spec/acfs/service/middleware_spec.rb
acfs-0.24.0.1.b214 spec/acfs/service/middleware_spec.rb
acfs-0.24.0.1.b212 spec/acfs/service/middleware_spec.rb
acfs-0.24.0.b210 spec/acfs/service/middleware_spec.rb
acfs-0.24.0 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b209 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b208 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b206 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b205 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b204 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b203 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b200 spec/acfs/service/middleware_spec.rb
acfs-0.23.2.b199 spec/acfs/service/middleware_spec.rb