Sha256: 53cc1ad29718c1c110e2346acfdfd15fa2e545e9aa241f05522e18edf48478f3
Contents?: true
Size: 982 Bytes
Versions: 1
Compression:
Stored size: 982 Bytes
Contents
shared_context :middleware_test do include_context :rack_test let(:inner_app) do proc { [200, {}, []] } end subject(:app) do described_class.new(inner_app) end def collect_middleware(rack_app) middleware = [rack_app] while (rack_app = rack_app.instance_variable_get(:@app)) middleware << rack_app end middleware end def find_middleware(rack_app, clazz) return rack_app if rack_app.is_a?(clazz) collect_middleware(rack_app).find { |middleware| middleware.is_a?(clazz) } end RSpec::Matchers.define :be_using do |expected, *_args| match do |actual| !find_middleware(actual, expected).nil? end end def create_middleware Class.new do attr_reader :app, :arg def initialize(app, arg = nil, &block) @app = app @arg = arg yield if block end def call(env) @app.call env end end end let(:middleware) do create_middleware end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sitehub-0.4.3 | spec/support/shared_contexts/middleware_context.rb |