Best Parallel_tests_ruby code snippet using ParallelTests.RSpec.spec_opts
runner.rb
Source:runner.rb
...4 class Runner < ParallelTests::Test::Runner5 def self.run_tests(test_files, process_number, options)6 exe = executable # expensive, so we cache7 version = (exe =~ /\brspec\b/ ? 2 : 1)8 cmd = "#{rspec_1_color if version == 1}#{exe} #{options[:test_options]} #{rspec_2_color if version == 2}#{spec_opts} #{test_files*' '}"9 execute_command(cmd, process_number, options)10 end11 def self.executable12 cmd = if File.file?("script/spec")13 "script/spec"14 elsif ParallelTests.bundler_enabled?15 cmd = (run("bundle show rspec") =~ %r{/rspec-1[^/]+$} ? "spec" : "rspec")16 "bundle exec #{cmd}"17 else18 %w[spec rspec].detect{|cmd| system "#{cmd} --version > /dev/null 2>&1" }19 end20 cmd or raise("Can't find executables rspec or spec")21 end22 def self.runtime_log23 'tmp/parallel_runtime_rspec.log'24 end25 def self.test_file_name26 "spec"27 end28 def self.test_suffix29 "_spec.rb"30 end31 private32 # so it can be stubbed....33 def self.run(cmd)34 `#{cmd}`35 end36 def self.rspec_1_color37 'RSPEC_COLOR=1 ; export RSPEC_COLOR ;' if $stdout.tty?38 end39 def self.rspec_2_color40 '--color --tty ' if $stdout.tty?41 end42 def self.spec_opts43 options_file = ['.rspec_parallel', 'spec/parallel_spec.opts', 'spec/spec.opts'].detect{|f| File.file?(f) }44 return unless options_file45 "-O #{options_file}"46 end47 end48 end49end...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!