Sha256: 81d9210409024e73bd781284220a3dfa8064767d805f09ee0c54f699cabd4872

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

class RecordingTelemetryTest < Minitest::Test
  def test_recording_telemetry
    output = StringIO.new
    telemetry = {}

    execute_with_telemetry telemetry, output

    assert_equal_telemetry expected_telemetry, telemetry
  end

  private

  def assert_equal_telemetry expected, actual
    expected.keys.each do |key|
      assert_equal expected[key], actual[key]
    end
  end

  def expected_telemetry
    {
      :input => { :up_to => 16 },
      :movements => {
        :make_array => {
          :input  => { :up_to => 16 },
          :output => { :array => [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] },
        },
        :apply_fizzbuzz => {
          :input  => { :array => [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] },
          :output => {
            :fizzbuzz => [
              "1",
              "2",
              "Fizz",
              "4",
              "Buzz",
              "Fizz",
              "7",
              "8",
              "Fizz",
              "Buzz",
              "11",
              "Fizz",
              "13",
              "14",
              "FizzBuzz",
            ],
          },
        },
        :__finally__ => {
          :input => {
            :fizzbuzz => [
              "1",
              "2",
              "Fizz",
              "4",
              "Buzz",
              "Fizz",
              "7",
              "8",
              "Fizz",
              "Buzz",
              "11",
              "Fizz",
              "13",
              "14",
              "FizzBuzz",
            ],
          },
          :output => { :__finally__ => [] },
        }
      },
      :output => [],
    }
  end

  def execute_with_telemetry telemetry, stdout
    conductor = Orchestra::Conductor.new :stdout => stdout

    conductor.add_observer TelemetryRecorder.new telemetry

    conductor.execute Examples::FizzBuzz, :up_to => 16
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.5 test/integration/recording_telemetry_test.rb