beforeRunningCommand saveActiveFile captureFormatString $0 capturePattern (/[^:]+):(\d+) command # Assumes the current file is a unittest/shoulda file # Runs with the currently-focused method as the test name #bin/sh args=$(${TM_RUBY:=ruby} <<"EOF" def parse_from_quotes(name) name.to_s.gsub(/^(?:.*"(.*)"|.*'(.*)').*$/) { $1 || $2 } end n = ENV['TM_LINE_NUMBER'].to_i INDENT = 2 # two spaces contexts, should, indent = [], nil, '' name, test_type = nil, nil File.open(ENV['TM_FILEPATH']) do |f| f.read.split("\n")[0...n].reverse_each do |line| if should if line =~ /^(\s*)context\b/ if $1 == indent # we must use indent to avoid stumbling on a context that's not for us contexts.unshift parse_from_quotes(line) indent = indent[0..(-INDENT - 1)] if indent.length < INDENT break end else # wrong indent, ignore end end elsif line =~ /^(\s*)should\b/ test_type = :shoulda should = parse_from_quotes(line) indent = $1[0..(-INDENT - 1)] elsif line =~ /^\s*def\s+(test_[\w_]+)/ test_type = :test_unit name = $1 break end end end if test_type == :shoulda if should && !contexts.empty? && !should.empty? #puts "shoulda" name = "#{contexts.join(' ')} should #{should}".gsub(/[\+\.\s\'\"\(\)]/,'.') print "--name=/#{name}/ -v v" end else 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 fileCaptureRegister 1 input document keyEquivalent @R lineCaptureRegister 2 name Run Focused Should output showAsHTML scope source.ruby.rails.shoulda uuid 6AFF5956-7774-4175-A005-9A03AF7F29B3