Class: ParallelRSpec::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_rspec/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel_to_server) ⇒ Client

Returns a new instance of Client.



34
35
36
# File 'lib/parallel_rspec/client.rb', line 34

def initialize(channel_to_server)
  @channel_to_server = channel_to_server
end

Instance Attribute Details

#channel_to_serverObject (readonly)

Returns the value of attribute channel_to_server.



32
33
34
# File 'lib/parallel_rspec/client.rb', line 32

def channel_to_server
  @channel_to_server
end

Instance Method Details

#deprecation(hash) ⇒ Object



58
59
60
# File 'lib/parallel_rspec/client.rb', line 58

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

#dumpable_exception(exception) ⇒ Object



74
75
76
77
# File 'lib/parallel_rspec/client.rb', line 74

def dumpable_exception(exception)
  return exception if exception.nil? || exception.is_a?(ExceptionMarshallingWrapper)
  ExceptionMarshallingWrapper.new(exception.class.name, exception.to_s, exception.backtrace, dumpable_exception(exception.cause))
end

#example_failed(example) ⇒ Object



46
47
48
# File 'lib/parallel_rspec/client.rb', line 46

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

#example_finished(example) ⇒ Object



50
51
52
# File 'lib/parallel_rspec/client.rb', line 50

def example_finished(example)
  channel_to_server.write([:example_finished, example.id, updates_from(example)])
end

#example_passed(example) ⇒ Object



42
43
44
# File 'lib/parallel_rspec/client.rb', line 42

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

#example_pending(example) ⇒ Object



54
55
56
# File 'lib/parallel_rspec/client.rb', line 54

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

#example_started(example) ⇒ Object



38
39
40
# File 'lib/parallel_rspec/client.rb', line 38

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

#next_example_to_runObject



79
80
81
82
83
# File 'lib/parallel_rspec/client.rb', line 79

def next_example_to_run
  return nil if RSpec.world.wants_to_quit
  channel_to_server.write([:next_example_to_run])
  channel_to_server.read
end

#result(success) ⇒ Object



85
86
87
# File 'lib/parallel_rspec/client.rb', line 85

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

#updates_from(example) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/parallel_rspec/client.rb', line 62

def updates_from(example)
  example.execution_result.exception = dumpable_exception(example.execution_result.exception)
  {
    exception: dumpable_exception(example.exception),
    metadata: example..slice(
      :execution_result,
      :pending,
      :skip,
    )
  }
end