Class: ThreadedRspec::ExampleGroupRunner
- Inherits:
-
Spec::Runner::ExampleGroupRunner
- Object
- Spec::Runner::ExampleGroupRunner
- ThreadedRspec::ExampleGroupRunner
- Defined in:
- lib/threaded_rspec/example_group_runner.rb
Instance Method Summary collapse
-
#initialize(options, thread_count) ⇒ ExampleGroupRunner
constructor
A new instance of ExampleGroupRunner.
- #run ⇒ Object
Constructor Details
#initialize(options, thread_count) ⇒ ExampleGroupRunner
Returns a new instance of ExampleGroupRunner.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/threaded_rspec/example_group_runner.rb', line 3 def initialize(, thread_count) super() @options = @thread_count = thread_count.to_i # parser = OptionParser.new do |p| # p.on('--thread-count N', Integer, # 'Number of concurrent threads.') do |n| # @thread_count = n # end # end # parser.parse!(options.argv) end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/threaded_rspec/example_group_runner.rb', line 17 def run prepare queue = Queue.new example_groups.each{|b| queue << b} success = true threads = [] @thread_count.times do threads << Thread.new(queue, @options) do |q, opts| success &= q.pop.run(opts) while !q.empty? end end threads.each{|t| t.join} success ensure finish end |