-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathRun Context.tmCommand
58 lines (49 loc) · 1.6 KB
/
Run Context.tmCommand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string># Assumes the current file is a unittest file
# Runs with the currently-focused method as the test name
args=$(${TM_RUBY:=ruby} <<"EOF"
def parse_from_quotes(name)
name.to_s.gsub(/^(?:.*"(.*)"|.*'(.*)').*$/) { $1 || $2 }
end
n = ENV['TM_LINE_NUMBER'].to_i
should, context = nil, nil
File.open(ENV['TM_FILEPATH']) do |f|
lines = f.read.split("\n")[0...n].reverse
context = lines.find { |line| line =~ /^\s*context\b/ }
should = parse_from_quotes(lines.find { |line| line =~ /^\s*should\b/ })
end
if !context.empty? && !should.empty?
puts "shoulda"
context = parse_from_quotes( context )
name = "#{context}".gsub(/[\+\.\s\'\"\(\)]/,'.')
print "--name=/#{name}/ -v v"
end
EOF)
if [[ -z "$args" ]]; then
echo -e "This doesn't appear to be a TestCase class."
exit_show_tool_tip
fi
export RUBYLIB="$TM_BUNDLE_SUPPORT/RubyMate${RUBYLIB:+:$RUBYLIB}"
"${TM_RUBY:-ruby}" -- "$TM_BUNDLE_SUPPORT/RubyMate/run_script.rb" $args</string>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>~@r</string>
<key>name</key>
<string>Run Context</string>
<key>output</key>
<string>showAsHTML</string>
<key>scope</key>
<string>source.ruby.rails.shoulda</string>
<key>uuid</key>
<string>2989704F-8F6B-439F-83A7-368BB174A010</string>
</dict>
</plist>