Ever wanted autocompletion for paths from paths.rb
in Cucumber? This card lets you write your steps like this:
When I go to path *press tab now* # path is replaced with a list of all known Cucumber paths
(key shortcuts apply for TextMate2)
Open the bundle editor (ctrl + alt + + B)
Create a new Item ( + N), select "Command"
Paste this:
^
#!/usr/bin/env ruby -wKU
require File.join(ENV['TM_SUPPORT_PATH'], 'lib', 'ui.rb')
cucumber_paths = File.join ENV['TM_PROJECT_DIRECTORY'], 'features', 'support', 'paths.rb'
if File.exist? cucumber_paths
lines = []
File.open(cucumber_paths, 'r').each do |line|
lines << line.slice(/\s+when /^?([^$]*)$?/[im]?$/, 1) # @param 1: return first matched group
end
paths = lines.compact.sort
TextMate::UI.complete(paths, :extra_chars => " ")
else
%x{ "$DIALOG" tooltip --html 'File /features/support/paths.rb not found.' }
end
Now you only need some more configuration:
text.gherkin.feature
You're done!