Sha256: 034787821986df4d1ba69d249d12f9c3143febdb71bf7fd24771a06809150048
Contents?: true
Size: 1.49 KB
Versions: 18
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Frodo::Middleware::Gzip do let(:options) { { oauth_token: 'token' } } # Return a gzipped string. def gzip(str) StringIO.new.tap do |io| gz = Zlib::GzipWriter.new(io) gz.write(str) gz.close end.string end describe '.call' do subject { lambda { middleware.call(env) } } before do expect(app).to receive(:on_complete) { middleware.on_complete(env) } expect(app).to receive(:call) do env[:body] = gzip fixture('leads') env[:response_headers]['Content-Encoding'] = 'gzip' app end end it 'decompresses the body' do should change { env[:body] }.to(fixture('leads')) end context 'when :compress is false' do it { should_not(change { env[:request_headers]['Accept-Encoding'] }) } end context 'when :compress is true' do before do options[:compress] = true end it { should(change { env[:request_headers]['Accept-Encoding'] }.to('gzip')) } end end describe '.decompress' do let(:body) { gzip fixture('leads') } subject { middleware.decompress(body) } it { should eq fixture('leads') } end describe '.gzipped?' do subject { middleware.gzipped?(env) } context 'when gzipped' do before do env[:response_headers]['Content-Encoding'] = 'gzip' end it { should be_truthy } end context 'when not gzipped' do it { should be_falsey } end end end
Version data entries
18 entries across 18 versions & 1 rubygems