Class: ParallelRSpec::Server
- Inherits:
-
Object
- Object
- ParallelRSpec::Server
- Defined in:
- lib/parallel_rspec/server.rb
Instance Attribute Summary collapse
-
#remaining_examples_by_group ⇒ Object
readonly
Returns the value of attribute remaining_examples_by_group.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#running_examples ⇒ Object
readonly
Returns the value of attribute running_examples.
Instance Method Summary collapse
- #deprecation(hash, channel_to_client) ⇒ Object
- #example_failed(example_id, example_updates, channel_to_client) ⇒ Object
- #example_finished(example_id, example_updates, channel_to_client) ⇒ Object
- #example_passed(example_id, example_updates, channel_to_client) ⇒ Object
- #example_pending(example_id, example_updates, channel_to_client) ⇒ Object
- #example_started(example_id, example_updates, channel_to_client) ⇒ Object
-
#initialize(reporter) ⇒ Server
constructor
A new instance of Server.
- #next_example_to_run(channel_to_client) ⇒ Object
- #result(success, channel_to_client) ⇒ Object
- #success? ⇒ Boolean
- #update_example(example, data) ⇒ Object
Constructor Details
#initialize(reporter) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 10 11 12 |
# File 'lib/parallel_rspec/server.rb', line 5 def initialize(reporter) @remaining_examples_by_group = RSpec.world.filtered_examples.each_with_object({}) do |(example_group, examples), results| results[example_group] = examples unless example_group.any_context_hooks? || examples.size.zero? end @reporter = reporter @success = true @running_examples = {} end |
Instance Attribute Details
#remaining_examples_by_group ⇒ Object (readonly)
Returns the value of attribute remaining_examples_by_group.
3 4 5 |
# File 'lib/parallel_rspec/server.rb', line 3 def remaining_examples_by_group @remaining_examples_by_group end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
3 4 5 |
# File 'lib/parallel_rspec/server.rb', line 3 def reporter @reporter end |
#running_examples ⇒ Object (readonly)
Returns the value of attribute running_examples.
3 4 5 |
# File 'lib/parallel_rspec/server.rb', line 3 def running_examples @running_examples end |
Instance Method Details
#deprecation(hash, channel_to_client) ⇒ Object
34 35 36 |
# File 'lib/parallel_rspec/server.rb', line 34 def deprecation(hash, channel_to_client) reporter.deprecation(hash) end |
#example_failed(example_id, example_updates, channel_to_client) ⇒ Object
26 27 28 |
# File 'lib/parallel_rspec/server.rb', line 26 def example_failed(example_id, example_updates, channel_to_client) reporter.example_failed(update_example(running_examples.delete(example_id), example_updates)) end |
#example_finished(example_id, example_updates, channel_to_client) ⇒ Object
18 19 20 |
# File 'lib/parallel_rspec/server.rb', line 18 def example_finished(example_id, example_updates, channel_to_client) reporter.example_finished(update_example(running_examples[example_id], example_updates)) end |
#example_passed(example_id, example_updates, channel_to_client) ⇒ Object
22 23 24 |
# File 'lib/parallel_rspec/server.rb', line 22 def example_passed(example_id, example_updates, channel_to_client) reporter.example_passed(update_example(running_examples.delete(example_id), example_updates)) end |
#example_pending(example_id, example_updates, channel_to_client) ⇒ Object
30 31 32 |
# File 'lib/parallel_rspec/server.rb', line 30 def example_pending(example_id, example_updates, channel_to_client) reporter.example_pending(update_example(running_examples.delete(example_id), example_updates)) end |
#example_started(example_id, example_updates, channel_to_client) ⇒ Object
14 15 16 |
# File 'lib/parallel_rspec/server.rb', line 14 def example_started(example_id, example_updates, channel_to_client) reporter.example_started(update_example(running_examples[example_id], example_updates)) end |
#next_example_to_run(channel_to_client) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/parallel_rspec/server.rb', line 38 def next_example_to_run(channel_to_client) if remaining_examples_by_group.empty? channel_to_client.write(nil) else example_group = remaining_examples_by_group.keys.first example = remaining_examples_by_group[example_group].pop running_examples[example.id] = example # cache so we don't need to look through all the examples for each message channel_to_client.write([example_group, remaining_examples_by_group[example_group].size]) remaining_examples_by_group.delete(example_group) if remaining_examples_by_group[example_group].empty? end end |
#result(success, channel_to_client) ⇒ Object
50 51 52 |
# File 'lib/parallel_rspec/server.rb', line 50 def result(success, channel_to_client) @success &&= success end |
#success? ⇒ Boolean
54 55 56 |
# File 'lib/parallel_rspec/server.rb', line 54 def success? @success end |
#update_example(example, data) ⇒ Object
58 59 60 61 62 |
# File 'lib/parallel_rspec/server.rb', line 58 def update_example(example, data) example.set_exception(data[:exception]) example..merge!(data[:metadata]) example end |