Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use mate or show! in irb to open in EDITOR

  • Loading branch information...
commit b7672753259038181343216e47523846e427a410 1 parent 4953825
Blake Mizerany authored
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, {}, '')
Please sign in to comment.
Something went wrong with that request. Please try again.