Sha256: ab08d3317504d5ee65db8a5ebe33a7da3d7778b21896ea5cfb841fc458357c28

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'

module Chillout
  module Middleware
    class CreationsMonitorTest < ChilloutTestCase
      def setup
        @env = { 'HOST' => 'example.net' }
        @logger = stub(info: "", debug: "")
        @client = stub(logger: @logger)
      end

      def call_with_model_creation
        @app = lambda do |env|
          Chillout.creations = :creations
          [200, env, ['hello']]
        end
        @middleware = CreationsMonitor.new(@app, @client)
      end

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

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

        @middleware.call(@env)
      end

      def call_without_model_creation
        @app = lambda do |env|
          [200, env, ['hello']]
        end
        @middleware = CreationsMonitor.new(@app, @client)
      end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chillout-0.8.9 test/middleware/creations_monitor_test.rb
chillout-0.8.5.1 test/middleware/creations_monitor_test.rb
chillout-0.8.8 test/middleware/creations_monitor_test.rb
chillout-0.8.7 test/middleware/creations_monitor_test.rb
chillout-0.8.6 test/middleware/creations_monitor_test.rb
chillout-0.8.5 test/middleware/creations_monitor_test.rb
chillout-0.8.4 test/middleware/creations_monitor_test.rb