Sha256: ffacd61dfd89ad3301817326febd813694048b97edd6080df972cc20a2bfaf4b

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path('../test_helper', __FILE__)

module Larva
  class ProcessorTest < Minitest::Test
    def test_initialize_should_extract_action_and_entity
      entity = "media_file"
      action = "processed"
      message = {entity: entity, action: action, media_file_id: "8"}
      processor = Processor.new(message)
      assert_equal entity, processor.entity
      assert_equal action, processor.action
    end

    class GoodProcessor < Processor
      def process
        true
      end
    end

    class BadProcessor < Processor
      def process
        false
      end
    end

    def test_process_logs_message
      message = {entity: "media_file", action: "processed", media_file_id: "8"}
      output = "Processing message: #{message}"
      Propono.config.logger.stubs(:info)
      Propono.config.logger.expects(:info).with(output)
      GoodProcessor.process(message)
    end

    def test_process_logs_success
      message = {entity: "media_file", action: "processed", media_file_id: "8"}
      output = "Message Processed: #{message}"
      Propono.config.logger.stubs(:info)
      Propono.config.logger.expects(:info).with(output)
      GoodProcessor.process(message)
    end

    def test_process_logs_message
      entity = "media_file"
      action = "processed"
      message = {entity: entity, action: action, media_file_id: "8"}
      output = "Unrecognized event type, entity: #{entity} action: #{action}."

      Propono.config.logger.stubs(:info)
      Propono.config.logger.expects(:info).with(output)
      BadProcessor.process(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
larva-0.3.0 test/processor_test.rb