Sha256: 7e42d7342d8349a3701deed4329e554ff4434efb6be8f763feae22212baf9f55

Contents?: true

Size: 1.08 KB

Versions: 15

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'rack/test'
require 'async_rack_test'

describe Firehose::Rack::Publisher, :type => :request do
  include AsyncRackTest::Methods
  let(:app) { Firehose::Rack::Publisher.new }
  let(:path) { "/test/path/#{Time.now.to_i}" }
  let(:deferrable) { EM::DefaultDeferrable.new }

  context 'publishing is successful' do
    before { deferrable.succeed }

    it "should return 202" do
      app.stub(:publisher => double('publisher', :publish => deferrable))
      aput path, :body => "some nice little message"
      last_response.status.should == 202
    end

    it "should have Content-Length of zero" do
      app.stub(:publisher => double('publisher', :publish => deferrable))
      aput path, :body => "some nice little message"
      last_response.headers['Content-Length'].should == '0'
    end

    it "should parse Cache-Control max-age" do
      body = "howdy dude!"
      ttl = '92'

      Firehose::Server::Publisher.any_instance.stub(:publish).with(path, body, :ttl => ttl).and_return(deferrable)
      aput path, body, 'HTTP_CACHE_CONTROL' => 'max-age=92'
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
firehose-1.2.20 spec/lib/rack/publisher_spec.rb
firehose-1.2.13 spec/lib/rack/publisher_spec.rb
firehose-1.2.12 spec/lib/rack/publisher_spec.rb
firehose-1.2.11 spec/lib/rack/publisher_spec.rb
firehose-1.2.10 spec/lib/rack/publisher_spec.rb
firehose-1.2.9 spec/lib/rack/publisher_spec.rb
firehose-1.2.8 spec/lib/rack/publisher_spec.rb
firehose-1.2.7 spec/lib/rack/publisher_spec.rb
firehose-1.2.6 spec/lib/rack/publisher_spec.rb
firehose-1.2.5 spec/lib/rack/publisher_spec.rb
firehose-1.2.4 spec/lib/rack/publisher_spec.rb
firehose-1.2.3 spec/lib/rack/publisher_spec.rb
firehose-1.2.2 spec/lib/rack/publisher_spec.rb
firehose-1.2.1 spec/lib/rack/publisher_spec.rb
firehose-1.2.0 spec/lib/rack/publisher_spec.rb