Sha256: b9d659e904223cf594f62c09cb46b86621822fa589ec1e34c97b155c23c41d07

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

module Chillout
  module Middleware
    class CreationsMonitorTest < ChilloutTestCase
      setup do
        @env = { 'HOST' => 'example.net' }
        @client = mock()
      end

      context "for call with model creation" do
        setup do
          @app = lambda do |env|
            Thread.current[:creations] = :creations
            [200, env, ['hello']]
          end
          @middleware = CreationsMonitor.new(@app, @client)
        end

        def test_behaves_like_rack_middleware
          @client.stubs(:enqueue)
          response = @middleware.call(@env)
          assert_equal [200, @env, ['hello']], response
        end

        def test_clients_queue_receive_creations
          @client.expects(:enqueue).with(:creations)

          @middleware.call(@env)
        end
      end

      context "for call without model creation" do
        setup do
          @app = lambda do |env|
            [200, env, ['hello']]
          end
          @middleware = CreationsMonitor.new(@app, @client)
        end

        def test_behaves_like_rack_middleware
          response = @middleware.call(@env)

          assert_equal [200, @env, ['hello']], response
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chillout-0.5.3 test/middleware/creations_monitor_test.rb
chillout-0.5.2 test/middleware/creations_monitor_test.rb
chillout-0.5.1 test/middleware/creations_monitor_test.rb
chillout-0.5.0 test/middleware/creations_monitor_test.rb
chillout-0.4.1 test/middleware/creations_monitor_test.rb
chillout-0.4.0 test/middleware/creations_monitor_test.rb
chillout-0.3.0 test/middleware/creations_monitor_test.rb
chillout-0.2.3 test/middleware/creations_monitor_test.rb
chillout-0.2.2 test/middleware/creations_monitor_test.rb