Skip to content

Instantly share code, notes, and snippets.

@andyl
Created July 29, 2012 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyl/3202065 to your computer and use it in GitHub Desktop.
Save andyl/3202065 to your computer and use it in GitHub Desktop.
Rspec Formatter for RubyMine
require 'rubygems'
require 'rspec/core/example'
require 'rspec/core/formatters/progress_formatter'
require 'colored'
class RSpec::Core::Example
attr_reader :example_block
end
# Custom formatter for Rspec - intended for use with RubyMine
# Auto-displays the failed spec in RubyMine
#
# to use:
# rspec -r /path/to/rm_auto_display_formatter.rb -f progress -f RmAutoDisplayFormatter --fail-fast
#
# tested on: Ubuntu 12.04, RubyMine 4.5, Ruby 1.9.3, Rspec 2.11
class RmAutoDisplayFormatter < RSpec::Core::Formatters::ProgressFormatter
RUBY_MINE_CMD = "/path/to/your/rubymine/bin/rubymine.sh"
def example_failed(example_obj)
target_file = example_obj.example_block.to_s.split(/\@|\>/).last
file, line = target_file.split(':')
cmd = "#{RUBY_MINE_CMD} --line #{line} #{file} &"
@output.puts "\n Failed Spec: #{target_file}".cyan
@output.puts "RubyMine Cmd: #{cmd}".cyan
system cmd
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment