Class: RSpec::Core::Parser
- Inherits:
-
Object
- Object
- RSpec::Core::Parser
- Defined in:
- lib/mrspec/add_options_to_rspec_parser.rb
Instance Method Summary collapse
-
#mrspec_parser(options, *args, &b) ⇒ Object
Ours calls RSpec’s, then modifies values on the returned parser.
- #print_mrspec_version(_opts, _err, out) ⇒ Object
Instance Method Details
#mrspec_parser(options, *args, &b) ⇒ Object
Ours calls RSpec’s, then modifies values on the returned parser
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mrspec/add_options_to_rspec_parser.rb', line 21 def mrspec_parser(, *args, &b) option_parser = rspec_parser(, *args, &b) # update the program name option_parser..gsub! /\brspec\b/, 'mrspec' # print mrspec version, and dependency versions. # calling exit and toplevel puts, b/c that's what RSpec's does https://github.com/rspec/rspec-core/blob/c7c1154934c42b5f6905bb7bd22025fe6c8a816c/lib/rspec/core/option_parser.rb#L290 # and I don't feel like figuring out how to work around it. option_parser.on('-v', '--version', 'Display the version.') do [:runner] = method :print_mrspec_version end format_description = option_parser.top.short['f'].desc first_option = format_description.find { |s| s[/\[[a-zA-Z]\]/] } leading_whitespace = first_option[/^\s*/] index = format_description.index first_option format_description.insert index, "#{leading_whitespace}[w]hat (we've got here is an error to communicate)" option_parser end |
#print_mrspec_version(_opts, _err, out) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/mrspec/add_options_to_rspec_parser.rb', line 55 def print_mrspec_version(_opts, _err, out) out.puts "mrspec #{MRspec::VERSION}\n"\ "rspec-core #{RSpec::Core::Version::STRING}\n"\ "minitest #{Minitest::VERSION}\n"\ "wwhhiae2c #{ErrorToCommunicate::VERSION}\n" end |