Skip to content

Instantly share code, notes, and snippets.

@apeckham
Created March 11, 2014 03:28
Show Gist options
  • Save apeckham/9478961 to your computer and use it in GitHub Desktop.
Save apeckham/9478961 to your computer and use it in GitHub Desktop.
command-shift-T (toggle between spec and implementation) for both coffeescript and ruby in rubymine
#!/usr/bin/env ruby
#http://pivotallabs.com/swapping-javascript-spec-implementation-rubymine/
file = ARGV[0] || raise
basename = File.basename(file)
basename_to_open = if file.include?('spec')
basename.sub /_spec\.(coffee|rb)/, '.\1'
else
basename.sub /\.(\w+)$/, '_spec.\1'
end
file_to_open = Dir['**/*'].find do |f|
File.basename(f) == basename_to_open
end
if file_to_open
system '/usr/local/bin/mine', file_to_open
else
puts "#{file}: No test subjects found"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment