Class: RSpec::Core::DrbOptions
- Inherits:
-
Object
- Object
- RSpec::Core::DrbOptions
- Defined in:
- lib/rspec/core/drb_options.rb
Instance Method Summary collapse
- #add_failure_exit_code(argv) ⇒ Object
- #add_filter(argv, name, hash) ⇒ Object
- #add_formatters(argv) ⇒ Object
- #add_full_description(argv) ⇒ Object
- #add_libs(argv) ⇒ Object
- #add_line_numbers(argv) ⇒ Object
- #add_requires(argv) ⇒ Object
-
#initialize(submitted_options, filter_manager) ⇒ DrbOptions
constructor
A new instance of DrbOptions.
- #options ⇒ Object
Constructor Details
#initialize(submitted_options, filter_manager) ⇒ DrbOptions
6 7 8 9 |
# File 'lib/rspec/core/drb_options.rb', line 6 def initialize(, filter_manager) = @filter_manager = filter_manager end |
Instance Method Details
#add_failure_exit_code(argv) ⇒ Object
33 34 35 36 37 |
# File 'lib/rspec/core/drb_options.rb', line 33 def add_failure_exit_code(argv) if [:failure_exit_code] argv << "--failure-exit-code" << [:failure_exit_code].to_s end end |
#add_filter(argv, name, hash) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/rspec/core/drb_options.rb', line 55 def add_filter(argv, name, hash) hash.each_pair do |k, v| next if [:if,:unless].include?(k) tag = name == :inclusion ? k.to_s : "~#{k}" tag << ":#{v}" if v.is_a?(String) argv << "--tag" << tag end unless hash.empty? end |
#add_formatters(argv) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/rspec/core/drb_options.rb', line 64 def add_formatters(argv) [:formatters].each do |pair| argv << "--format" << pair[0] argv << "--out" << pair[1] if pair[1] end if [:formatters] end |
#add_full_description(argv) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/rspec/core/drb_options.rb', line 39 def add_full_description(argv) if [:full_description] # The argument to --example is regexp-escaped before being stuffed # into a regexp when received for the first time (see OptionParser). # Hence, merely grabbing the source of this regexp will retain the # backslashes, so we must remove them. argv << "--example" << [:full_description].source.delete('\\') end end |
#add_libs(argv) ⇒ Object
71 72 73 74 75 |
# File 'lib/rspec/core/drb_options.rb', line 71 def add_libs(argv) [:libs].each do |path| argv << "-I" << path end if [:libs] end |
#add_line_numbers(argv) ⇒ Object
49 50 51 52 53 |
# File 'lib/rspec/core/drb_options.rb', line 49 def add_line_numbers(argv) if [:line_numbers] argv.push(*[:line_numbers].inject([]){|a,l| a << "--line_number" << l}) end end |
#add_requires(argv) ⇒ Object
77 78 79 80 81 |
# File 'lib/rspec/core/drb_options.rb', line 77 def add_requires(argv) [:requires].each do |path| argv << "--require" << path end if [:requires] end |
#options ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/core/drb_options.rb', line 11 def argv = [] argv << "--color" if [:color] argv << "--profile" if [:profile_examples] argv << "--backtrace" if [:full_backtrace] argv << "--tty" if [:tty] argv << "--fail-fast" if [:fail_fast] argv << "--options" << [:custom_options_file] if [:custom_options_file] argv << "--order" << [:order] if [:order] add_failure_exit_code(argv) add_full_description(argv) add_line_numbers(argv) add_filter(argv, :inclusion, @filter_manager.inclusions) add_filter(argv, :exclusion, @filter_manager.exclusions) add_formatters(argv) add_libs(argv) add_requires(argv) argv + [:files_or_directories_to_run] end |