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
Returns a new instance of DrbOptions.
6 7 8 9 |
# File 'lib/rspec/core/drb_options.rb', line 6 def initialize(, filter_manager) @submitted_options = @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 @submitted_options[:failure_exit_code] argv << "--failure-exit-code" << @submitted_options[: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) @submitted_options[:formatters].each do |pair| argv << "--format" << pair[0] argv << "--out" << pair[1] if pair[1] end if @submitted_options[: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 @submitted_options[: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" << @submitted_options[: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) @submitted_options[:libs].each do |path| argv << "-I" << path end if @submitted_options[: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 @submitted_options[:line_numbers] argv.push(*@submitted_options[: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) @submitted_options[:requires].each do |path| argv << "--require" << path end if @submitted_options[: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 @submitted_options[:color] argv << "--profile" if @submitted_options[:profile_examples] argv << "--backtrace" if @submitted_options[:full_backtrace] argv << "--tty" if @submitted_options[:tty] argv << "--fail-fast" if @submitted_options[:fail_fast] argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file] argv << "--order" << @submitted_options[:order] if @submitted_options[: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 + @submitted_options[:files_or_directories_to_run] end |