Sha256: 10652024bca41526be63ad0068755e11cf93e7586b177141c0abcf6f2f3de7d5
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' describe LoggerWare::Rack do class App def call(env) [200, {a: 'b'}, 'ok'] end end class ErrApp def call(env) raise 'foo' end end it 'should allow setting filters' do LoggerWare::Rack.filters.should == [/password/] LoggerWare::Rack.filters << 'qwe' LoggerWare::Rack.filters.should == [/password/, 'qwe'] end it 'should call handler' do opts = nil LoggerWare::Rack.handler = ->(args) {opts = args} LoggerWare::Rack.new(App.new).call({}).should == [200, {a: 'b'}, 'ok'] opts[:status].should == 200 opts[:response].should == 'ok' opts.keys.should == [:status, :headers, :response, :started_at, :duration, :data] end it 'should call error handler' do opts = nil LoggerWare::Rack.handler = ->(args) {opts = args} err = nil LoggerWare::Rack.error_handler = ->(args) {err = args} -> { LoggerWare::Rack.new(ErrApp.new).call({}) }.should raise_error('foo') err[:exception].to_s.should == 'foo' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logger_ware-0.0.2 | spec/lib/logger_ware/rack_spec.rb |
logger_ware-0.0.1 | spec/lib/logger_ware/rack_spec.rb |