Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Deprecate get_it, post_it, etc. test helpers with warnings

  • Loading branch information...
commit 91922b78a7f636b70209271534154ab8815cb468 1 parent 1fb5b99
@rtomayko rtomayko authored
Showing with 11 additions and 1 deletion.
  1. +4 −0 CHANGES
  2. +7 −1 lib/sinatra/test.rb
View
4 CHANGES
@@ -68,6 +68,10 @@
treated as internal server errors and result in a 500 response
status.
+ * Deprecated the "get_it", "post_it", "put_it", "delete_it", and "head_it"
+ test helper methods. Use "get", "post", "put", "delete", and "head",
+ respectively, instead.
+
* Removed Event and EventContext classes. Applications are defined in a
subclass of Sinatra::Base; each request is processed within an
instance.
View
8 lib/sinatra/test.rb
@@ -85,13 +85,19 @@ def param_string(hash)
if defined? Sinatra::Compat
# Deprecated. Use: "get" instead of "get_it".
%w(get head post put delete).each do |verb|
- alias_method "#{verb}_it", verb
+ eval <<-RUBY, binding, __FILE__, __LINE__
+ def #{verb}_it(*args, &block)
+ sinatra_warn "The #{verb}_it method is deprecated; use #{verb} instead."
+ test_request('#{verb.upcase}', *args, &block)
+ end
+ RUBY
end
# Deprecated. Tests no longer delegate missing methods to the
# mock response. Use: @response
def method_missing(name, *args, &block)
if @response && @response.respond_to?(name)
+ sinatra_warn "The #{name} method is deprecated; use @response.#{name} instead."
@response.send(name, *args, &block)
else
super
Please sign in to comment.
Something went wrong with that request. Please try again.