lib/respec/app.rb in respec-0.7.0 vs lib/respec/app.rb in respec-0.8.0

- old
+ new

@@ -9,26 +9,27 @@ else @args = args @raw_args = [] end @failures_path = self.class.default_failures_path - @selected_failures = false @update_failures = true process_args end attr_accessor :failures_path def command - @command ||= bundler_args + ['rspec'] + generated_args + raw_args + formatter_args + @command ||= program_args + generated_args + raw_args + formatter_args end - def bundler_args - if File.exist?(ENV['BUNDLE_GEMFILE'] || 'Gemfile') - ['bundle', 'exec'] + def program_args + if File.exist?('bin/rspec') + ['bin/rspec'] + elsif File.exist?(ENV['BUNDLE_GEMFILE'] || 'Gemfile') + ['bundle', 'exec', 'rspec'] else - [] + ['rspec'] end end attr_reader :generated_args, :raw_args @@ -98,29 +99,27 @@ if File.exist?(failures_path) if failures.empty? STDERR.puts "No specs failed!" [] else - @selected_failures = true - failures + failures.flat_map { |f| ['-e', f] } end else warn "no fail file - ignoring 'f' argument" [] end end elsif arg =~ /\A\d+\z/ i = Integer(arg) if (failure = failures[i - 1]) - args << failure - @selected_failures = true + args << '-e' << failure @update_failures = false else warn "invalid failure: #{i} for (1..#{failures.size})" end else - args << '--example' << arg.gsub(/[$]/, '\\\\\\0') + args << '-e' << arg.gsub(/[$]/, '\\\\\\0') end end expanded = [] args.each do |arg| @@ -136,10 +135,10 @@ files << 'spec' if files.empty? # If we selected individual failures to rerun, don't give the files to # rspec, as those files will be run in their entirety. @generated_args = expanded - @generated_args.concat(files) unless @selected_failures + @generated_args.concat(files) end def failures @failures ||= if File.exist?(failures_path)