Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # vi: ft=ruby
- RSPEC_CMD = 'bundle exec rspec --no-color'
- VIM_CMD = 'gvim'
- EXTRA_FILE_WITH = 'e' # use sp to split open
- # Append additional command line argument to rspec command
- rspec_command = ARGV.unshift(RSPEC_CMD).join(' ')
- file_lines, last_trace = [], {}
- `#{rspec_command}`.split("\n").each do |line|
- mat = line.match(/\A\s*\#\s+(.+):(\d+)/)
- if mat # matched a backtrace line
- last_trace[mat[1]] = mat[2]
- next
- end
- mat = line.match(/\Arspec\s+(.+):(\d+)/)
- next unless mat
- file, line = mat[1], last_trace[mat[1]]
- file_lines << "+#{line} #{file}"
- end
- exit if file_lines.empty? # no error detected
- # add files with line number to open by vim
- vim_command = [VIM_CMD, file_lines.shift]
- file_lines.each { |f| vim_command << %Q|+"#{EXTRA_FILE_WITH} #{f}"| }
- # execute the vim command
- system vim_command.join(' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement