Class: TestLauncher::CLI::InputParser
- Inherits:
-
Object
- Object
- TestLauncher::CLI::InputParser
- Defined in:
- lib/test_launcher/cli/input_parser.rb
Constant Summary collapse
- ParseError =
Class.new(RuntimeError)
- BANNER =
<<-DESC Find tests and run them by trying to match an individual test or the name of a test file(s). See full README: https://github.com/petekinnecom/test_launcher Usage: `test_launcher "search string" [--all]` VERSION: #{TestLauncher::VERSION} DESC
Instance Method Summary collapse
-
#initialize(args, env) ⇒ InputParser
constructor
A new instance of InputParser.
- #options ⇒ Object
- #parsed_options(shell:, searcher:) ⇒ Object
Constructor Details
#initialize(args, env) ⇒ InputParser
Returns a new instance of InputParser.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/test_launcher/cli/input_parser.rb', line 27 def initialize(args, env) @search_string = args @env = env @options = {} option_parser.parse!(args) rescue OptionParser::ParseError puts "Invalid arguments" puts "----" puts option_parser exit end |
Instance Method Details
#options ⇒ Object
79 80 81 |
# File 'lib/test_launcher/cli/input_parser.rb', line 79 def @options end |
#parsed_options(shell:, searcher:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/test_launcher/cli/input_parser.rb', line 39 def (shell:, searcher:) if @search_string.size == 0 && !@options[:rerun] puts "Enter a search term" puts "----" puts option_parser exit elsif @search_string.size > 0 && @options[:rerun] puts "Cannot specify search terms and use --rerun flag" puts "----" puts option_parser exit end frameworks = if @options[:framework] == "rspec" [Frameworks::RSpec] elsif @options[:framework] == "minitest" [Frameworks::Minitest] elsif @options[:framework] == "ex_unit" [Frameworks::ExUnit] elsif @options[:framework] == "generic" [Frameworks::Generic] else [Frameworks::Minitest, Frameworks::RSpec, Frameworks::ExUnit, Frameworks::Generic] end Options.new( search_string: @search_string.join(" "), run_all: !!@options[:run_all], rerun: !!@options[:rerun], disable_spring: @options[:disable_spring] || !!@env["DISABLE_SPRING"], force_spring: @options[:force_spring], example_name: @options[:name], frameworks: frameworks, shell: shell, searcher: searcher ) end |