lib/respec/app.rb in respec-0.1.1 vs lib/respec/app.rb in respec-0.2.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'set' + module Respec class App def initialize(*args) if (i = args.index('--')) @args = args.slice!(0...i) @@ -38,11 +40,11 @@ attr_reader :generated_args, :raw_args class << self attr_accessor :failures_path end - self.failures_path = ENV['RESPEC_FAILURES'] || File.expand_path("~/.respec_failures") + self.failures_path = ENV['RESPEC_FAILURES'] || File.expand_path(".respec_failures") def help_only? @help_only end @@ -71,12 +73,19 @@ private def process_args args = [] files = [] + pass_next_arg = false @args.each do |arg| - if File.exist?(arg.sub(/:\d+\z/, '')) + if pass_next_arg + args << arg + pass_next_arg = false + elsif rspec_option_that_requires_an_argument?(arg) + args << arg + pass_next_arg = true + elsif File.exist?(arg.sub(/:\d+\z/, '')) files << arg elsif arg =~ /\A(--)?help\z/ @help_only = true elsif arg =~ /\A-/ args << arg @@ -124,7 +133,28 @@ File.read(failures_path).split(/\n/) else [] end end + + def rspec_option_that_requires_an_argument?(arg) + RSPEC_OPTIONS_THAT_REQUIRE_AN_ARGUMENT.include?(arg) + end + + RSPEC_OPTIONS_THAT_REQUIRE_AN_ARGUMENT = %w[ + -I + -r --require + -O --options + --order + --seed + --failure-exit-code + --drb-port + -f --format + -o --out + -P --pattern + -e --example + -l --line_number + -t --tag + --default_path + ].to_set end end