Sha256: 05d2c6b364087bd66d565ba7991225e3dcec1c73224b54de94ebd73057eebf18

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'
require 'observed/observed_task_factory'

describe Observed::ObservedTaskFactory do
  subject {
    Observed::ObservedTaskFactory.new
  }
  it 'should convert observers, translators, reporters to tasks' do
    output = mock('output')

    the_observer = Class.new(Observed::Observer) do
      def observe(data)
        data.merge(b:2)
      end
    end.new
    the_reporter = Class.new(Observed::Reporter) do
      attribute :output
      def report(tag, time, data)
        output.write(tag: tag, time: time, data: data)
      end
    end.new(output: output)
    the_translator = Class.new(Observed::Translator) do
      def translate(tag, time, data)
        data.merge(c:3)
      end
    end.new
    task = subject.convert_to_task(the_observer)
      .then(subject.convert_to_task(the_translator))
      .then(subject.convert_to_task(the_reporter))
    tag = 'the_tag'
    time = Time.now
    output.expects(:write).with(tag: tag, time: time, data: {a:1,b:2,c:3})
    task.now({a:1}, {tag: tag, time: time})
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
observed-0.2.0 spec/observed_task_factory_spec.rb
observed-0.2.0.rc2 spec/observed_task_factory_spec.rb