Class: TestBoosters::Rspec::Booster
- Inherits:
-
Object
- Object
- TestBoosters::Rspec::Booster
- Defined in:
- lib/test_boosters/rspec/booster.rb
Instance Attribute Summary collapse
-
#thread_count ⇒ Object
readonly
Returns the value of attribute thread_count.
-
#thread_index ⇒ Object
readonly
Returns the value of attribute thread_index.
Instance Method Summary collapse
- #all_leftover_specs ⇒ Object
- #all_specs ⇒ Object
-
#initialize(thread_index, thread_count) ⇒ Booster
constructor
A new instance of Booster.
- #run ⇒ Object
- #specs_path ⇒ Object
- #split_configuration ⇒ Object
- #split_configuration_path ⇒ Object
- #threads ⇒ Object
Constructor Details
#initialize(thread_index, thread_count) ⇒ Booster
Returns a new instance of Booster.
8 9 10 11 |
# File 'lib/test_boosters/rspec/booster.rb', line 8 def initialize(thread_index, thread_count) @thread_index = thread_index @thread_count = thread_count end |
Instance Attribute Details
#thread_count ⇒ Object (readonly)
Returns the value of attribute thread_count.
6 7 8 |
# File 'lib/test_boosters/rspec/booster.rb', line 6 def thread_count @thread_count end |
#thread_index ⇒ Object (readonly)
Returns the value of attribute thread_index.
5 6 7 |
# File 'lib/test_boosters/rspec/booster.rb', line 5 def thread_index @thread_index end |
Instance Method Details
#all_leftover_specs ⇒ Object
38 39 40 |
# File 'lib/test_boosters/rspec/booster.rb', line 38 def all_leftover_specs @all_leftover_specs ||= all_specs - split_configuration.all_files end |
#all_specs ⇒ Object
34 35 36 |
# File 'lib/test_boosters/rspec/booster.rb', line 34 def all_specs @all_specs ||= Dir["#{specs_path}/**/*_spec.rb"].sort end |
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/test_boosters/rspec/booster.rb', line 13 def run TestBoosters::Shell.display_title("RSpec Booster v#{TestBoosters::VERSION}") unless split_configuration.valid? puts "[ERROR] The split configuration file is malformed!" return 1 # failure exit status end threads[@thread_index].run end |
#specs_path ⇒ Object
46 47 48 |
# File 'lib/test_boosters/rspec/booster.rb', line 46 def specs_path @specs_path ||= ENV["SPEC_PATH"] || "spec" end |
#split_configuration ⇒ Object
42 43 44 |
# File 'lib/test_boosters/rspec/booster.rb', line 42 def split_configuration @split_configuration ||= TestBoosters::SplitConfiguration.new(split_configuration_path) end |
#split_configuration_path ⇒ Object
50 51 52 |
# File 'lib/test_boosters/rspec/booster.rb', line 50 def split_configuration_path ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/rspec_split_configuration.json" end |
#threads ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/test_boosters/rspec/booster.rb', line 25 def threads @threads ||= Array.new(@thread_count) do |thread_index| known_files = all_specs & split_configuration.files_for_thread(thread_index) leftover_files = TestBoosters::LeftoverFiles.select(all_leftover_specs, thread_count, thread_index) TestBoosters::Rspec::Thread.new(known_files, leftover_files) end end |