Skip to content

Commit

Permalink
Use mate or show! in irb to open in EDITOR
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Mizerany committed Oct 4, 2007
1 parent 4953825 commit b767275
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/sinatra/test_methods.rb
Expand Up @@ -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, {}, '')
Expand Down

0 comments on commit b767275

Please sign in to comment.