Sha256: 745ebcc33b93648c44877a10e74962a1fec69282827f45c6336d780b21eb35df

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

module ParallelRSpec
  class Client
    attr_reader :channel_to_server

    def initialize(channel_to_server)
      @channel_to_server = channel_to_server
    end

    def example_group_started(group)
      # not implemented yet - would need the same extraction/simplification for serialization as Example below
    end

    def example_group_finished(group)
      # ditto
    end

    def example_started(example)
      channel_to_server.write([:example_started, serialize_example(example)])
    end

    def example_passed(example)
      channel_to_server.write([:example_passed, serialize_example(example)])
    end

    def example_failed(example)
      channel_to_server.write([:example_failed, serialize_example(example)])
    end

    def example_pending(example)
      channel_to_server.write([:example_pending, serialize_example(example)])
    end

    def deprecation(hash)
      channel_to_server.write([:deprecation, hash])
    end

    def serialize_example(example)
      Example.new(
        example.id,
        example.description,
        example.exception,
        example.location_rerun_argument,
        example.metadata.slice(
          :absolute_file_path,
          :described_class,
          :description,
          :description_args,
          :execution_result,
          :full_description,
          :file_path,
          :last_run_status,
          :line_number,
          :location,
          :pending,
          :rerun_file_path,
          :scoped_id,
          :shared_group_inclusion_backtrace,
          :type))
    end

    def next_example_to_run
      channel_to_server.write([:next_example_to_run])
      channel_to_server.read
    end

    def result(success)
      channel_to_server.write([:result, success])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parallel_rspec-0.4.1 lib/parallel_rspec/client.rb