diff --git a/Support/lib/rspec/mate/switch_command.rb b/Support/lib/rspec/mate/switch_command.rb index d5f2cdd4a..35c3490a3 100644 --- a/Support/lib/rspec/mate/switch_command.rb +++ b/Support/lib/rspec/mate/switch_command.rb @@ -176,13 +176,11 @@ def klass(relative_path, content=nil) def write_and_open(path, content) `mkdir -p "#{File.dirname(path)}"` - `touch "#{path}"` + File.open(path, 'w') do |f| + f.write "# -*- encoding : utf-8 -*- +require 'spec_helper'" + end `"$TM_SUPPORT_PATH/bin/mate" "#{path}"` - `osascript &>/dev/null -e 'tell app "SystemUIServer" to activate' -e 'tell app "TextMate" to activate'` - - escaped_content = content.gsub("\n","\\n").gsub('$','\\$').gsub('"','\\\\\\\\\\\\"') - - `osascript &>/dev/null -e "tell app \\"TextMate\\" to insert \\"#{escaped_content}\\" as snippet true"` end end end