Browse files

Use mate or show! in irb to open in EDITOR

  • Loading branch information...
1 parent 4953825 commit b7672753259038181343216e47523846e427a410 Blake Mizerany committed Oct 4, 2007
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/sinatra/test_methods.rb
View
19 lib/sinatra/test_methods.rb
@@ -13,6 +13,25 @@ def #{verb}_it(path, params = {})
end
end_eval
end
+
+ def show!(editor = nil)
+ editor = editor || ENV['EDITOR']
+ IO.popen(editor, 'w') do |f|
+ f.puts "<!--"
+ f.puts result_info
+ f.puts "-->"
+ f.puts
+ f.puts body
+ end
+ end
+ alias :mate :show!
+
+ def result_info
+ info = <<-end_info
+ # Status: #{status}
+ # Headers: #{headers.inspect}
+ end_info
+ end
def response
@response || Rack::MockResponse.new(404, {}, '')

0 comments on commit b767275

Please sign in to comment.