Deprecate deprecated assertions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4938 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
65ca0db3f6
commit
761f1f1f3a
@ -6,31 +6,37 @@ module DeprecatedAssertions
|
|||||||
def assert_success(message=nil) #:nodoc:
|
def assert_success(message=nil) #:nodoc:
|
||||||
assert_response(:success, message)
|
assert_response(:success, message)
|
||||||
end
|
end
|
||||||
|
deprecate :assert_success
|
||||||
|
|
||||||
def assert_redirect(message=nil) #:nodoc:
|
def assert_redirect(message=nil) #:nodoc:
|
||||||
assert_response(:redirect, message)
|
assert_response(:redirect, message)
|
||||||
end
|
end
|
||||||
|
deprecate :assert_redirect
|
||||||
|
|
||||||
def assert_rendered_file(expected=nil, message=nil) #:nodoc:
|
def assert_rendered_file(expected=nil, message=nil) #:nodoc:
|
||||||
assert_template(expected, message)
|
assert_template(expected, message)
|
||||||
end
|
end
|
||||||
|
deprecate :assert_rendered_file
|
||||||
|
|
||||||
# ensure that the session has an object with the specified name
|
# ensure that the session has an object with the specified name
|
||||||
def assert_session_has(key=nil, message=nil) #:nodoc:
|
def assert_session_has(key=nil, message=nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> is not in the session <?>", key, @response.session)
|
msg = build_message(message, "<?> is not in the session <?>", key, @response.session)
|
||||||
assert_block(msg) { @response.has_session_object?(key) }
|
assert_block(msg) { @response.has_session_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_session_has
|
||||||
|
|
||||||
# ensure that the session has no object with the specified name
|
# ensure that the session has no object with the specified name
|
||||||
def assert_session_has_no(key=nil, message=nil) #:nodoc:
|
def assert_session_has_no(key=nil, message=nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> is in the session <?>", key, @response.session)
|
msg = build_message(message, "<?> is in the session <?>", key, @response.session)
|
||||||
assert_block(msg) { !@response.has_session_object?(key) }
|
assert_block(msg) { !@response.has_session_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_session_has_no
|
||||||
|
|
||||||
def assert_session_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
def assert_session_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> expected in session['?'] but was <?>", expected, key, @response.session[key])
|
msg = build_message(message, "<?> expected in session['?'] but was <?>", expected, key, @response.session[key])
|
||||||
assert_block(msg) { expected == @response.session[key] }
|
assert_block(msg) { expected == @response.session[key] }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_session_equal
|
||||||
|
|
||||||
# -- cookie assertions ---------------------------------------------------
|
# -- cookie assertions ---------------------------------------------------
|
||||||
|
|
||||||
@ -39,6 +45,7 @@ def assert_no_cookie(key = nil, message = nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> not expected in cookies['?']", actual, key)
|
msg = build_message(message, "<?> not expected in cookies['?']", actual, key)
|
||||||
assert_block(msg) { actual.nil? or actual.empty? }
|
assert_block(msg) { actual.nil? or actual.empty? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_no_cookie
|
||||||
|
|
||||||
def assert_cookie_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
def assert_cookie_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
||||||
actual = @response.cookies[key]
|
actual = @response.cookies[key]
|
||||||
@ -46,6 +53,7 @@ def assert_cookie_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, actual)
|
msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, actual)
|
||||||
assert_block(msg) { expected == actual }
|
assert_block(msg) { expected == actual }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_cookie_equal
|
||||||
|
|
||||||
# -- flash assertions ---------------------------------------------------
|
# -- flash assertions ---------------------------------------------------
|
||||||
|
|
||||||
@ -54,41 +62,48 @@ def assert_flash_has(key=nil, message=nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> is not in the flash <?>", key, @response.flash)
|
msg = build_message(message, "<?> is not in the flash <?>", key, @response.flash)
|
||||||
assert_block(msg) { @response.has_flash_object?(key) }
|
assert_block(msg) { @response.has_flash_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_has
|
||||||
|
|
||||||
# ensure that the flash has no object with the specified name
|
# ensure that the flash has no object with the specified name
|
||||||
def assert_flash_has_no(key=nil, message=nil) #:nodoc:
|
def assert_flash_has_no(key=nil, message=nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> is in the flash <?>", key, @response.flash)
|
msg = build_message(message, "<?> is in the flash <?>", key, @response.flash)
|
||||||
assert_block(msg) { !@response.has_flash_object?(key) }
|
assert_block(msg) { !@response.has_flash_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_has_no
|
||||||
|
|
||||||
# ensure the flash exists
|
# ensure the flash exists
|
||||||
def assert_flash_exists(message=nil) #:nodoc:
|
def assert_flash_exists(message=nil) #:nodoc:
|
||||||
msg = build_message(message, "the flash does not exist <?>", @response.session['flash'] )
|
msg = build_message(message, "the flash does not exist <?>", @response.session['flash'] )
|
||||||
assert_block(msg) { @response.has_flash? }
|
assert_block(msg) { @response.has_flash? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_exists
|
||||||
|
|
||||||
# ensure the flash does not exist
|
# ensure the flash does not exist
|
||||||
def assert_flash_not_exists(message=nil) #:nodoc:
|
def assert_flash_not_exists(message=nil) #:nodoc:
|
||||||
msg = build_message(message, "the flash exists <?>", @response.flash)
|
msg = build_message(message, "the flash exists <?>", @response.flash)
|
||||||
assert_block(msg) { !@response.has_flash? }
|
assert_block(msg) { !@response.has_flash? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_not_exists
|
||||||
|
|
||||||
# ensure the flash is empty but existent
|
# ensure the flash is empty but existent
|
||||||
def assert_flash_empty(message=nil) #:nodoc:
|
def assert_flash_empty(message=nil) #:nodoc:
|
||||||
msg = build_message(message, "the flash is not empty <?>", @response.flash)
|
msg = build_message(message, "the flash is not empty <?>", @response.flash)
|
||||||
assert_block(msg) { !@response.has_flash_with_contents? }
|
assert_block(msg) { !@response.has_flash_with_contents? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_empty
|
||||||
|
|
||||||
# ensure the flash is not empty
|
# ensure the flash is not empty
|
||||||
def assert_flash_not_empty(message=nil) #:nodoc:
|
def assert_flash_not_empty(message=nil) #:nodoc:
|
||||||
msg = build_message(message, "the flash is empty")
|
msg = build_message(message, "the flash is empty")
|
||||||
assert_block(msg) { @response.has_flash_with_contents? }
|
assert_block(msg) { @response.has_flash_with_contents? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_not_empty
|
||||||
|
|
||||||
def assert_flash_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
def assert_flash_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> expected in flash['?'] but was <?>", expected, key, @response.flash[key])
|
msg = build_message(message, "<?> expected in flash['?'] but was <?>", expected, key, @response.flash[key])
|
||||||
assert_block(msg) { expected == @response.flash[key] }
|
assert_block(msg) { expected == @response.flash[key] }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_flash_equal
|
||||||
|
|
||||||
|
|
||||||
# ensure our redirection url is an exact match
|
# ensure our redirection url is an exact match
|
||||||
@ -97,6 +112,7 @@ def assert_redirect_url(url=nil, message=nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> is not the redirected location <?>", url, @response.redirect_url)
|
msg = build_message(message, "<?> is not the redirected location <?>", url, @response.redirect_url)
|
||||||
assert_block(msg) { @response.redirect_url == url }
|
assert_block(msg) { @response.redirect_url == url }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_redirect_url
|
||||||
|
|
||||||
# ensure our redirection url matches a pattern
|
# ensure our redirection url matches a pattern
|
||||||
def assert_redirect_url_match(pattern=nil, message=nil) #:nodoc:
|
def assert_redirect_url_match(pattern=nil, message=nil) #:nodoc:
|
||||||
@ -104,6 +120,7 @@ def assert_redirect_url_match(pattern=nil, message=nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> was not found in the location: <?>", pattern, @response.redirect_url)
|
msg = build_message(message, "<?> was not found in the location: <?>", pattern, @response.redirect_url)
|
||||||
assert_block(msg) { @response.redirect_url_match?(pattern) }
|
assert_block(msg) { @response.redirect_url_match?(pattern) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_redirect_url_match
|
||||||
|
|
||||||
|
|
||||||
# -- template assertions ------------------------------------------------
|
# -- template assertions ------------------------------------------------
|
||||||
@ -113,12 +130,14 @@ def assert_template_has(key=nil, message=nil) #:nodoc:
|
|||||||
msg = build_message(message, "<?> is not a template object", key )
|
msg = build_message(message, "<?> is not a template object", key )
|
||||||
assert_block(msg) { @response.has_template_object?(key) }
|
assert_block(msg) { @response.has_template_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_template_has
|
||||||
|
|
||||||
# ensure that a template object with the given name does not exist
|
# ensure that a template object with the given name does not exist
|
||||||
def assert_template_has_no(key=nil,message=nil) #:nodoc:
|
def assert_template_has_no(key=nil,message=nil) #:nodoc:
|
||||||
msg = build_message(message, "<?> is a template object <?>", key, @response.template_objects[key])
|
msg = build_message(message, "<?> is a template object <?>", key, @response.template_objects[key])
|
||||||
assert_block(msg) { !@response.has_template_object?(key) }
|
assert_block(msg) { !@response.has_template_object?(key) }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_template_has_no
|
||||||
|
|
||||||
# ensures that the object assigned to the template on +key+ is equal to +expected+ object.
|
# ensures that the object assigned to the template on +key+ is equal to +expected+ object.
|
||||||
def assert_template_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
def assert_template_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
||||||
@ -126,6 +145,8 @@ def assert_template_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
|||||||
assert_block(msg) { expected == @response.template.assigns[key.to_s] }
|
assert_block(msg) { expected == @response.template.assigns[key.to_s] }
|
||||||
end
|
end
|
||||||
alias_method :assert_assigned_equal, :assert_template_equal
|
alias_method :assert_assigned_equal, :assert_template_equal
|
||||||
|
deprecate :assert_assigned_equal
|
||||||
|
deprecate :assert_template_equal
|
||||||
|
|
||||||
# Asserts that the template returns the +expected+ string or array based on the XPath +expression+.
|
# Asserts that the template returns the +expected+ string or array based on the XPath +expression+.
|
||||||
# This will only work if the template rendered a valid XML document.
|
# This will only work if the template rendered a valid XML document.
|
||||||
@ -143,6 +164,7 @@ def assert_template_xpath_match(expression=nil, expected=nil, message=nil) #:nod
|
|||||||
msg = build_message(message, "<?> found <?>, not <?>", expression, matches, expected)
|
msg = build_message(message, "<?> found <?>, not <?>", expression, matches, expected)
|
||||||
assert_block(msg) { matches == expected }
|
assert_block(msg) { matches == expected }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_template_xpath_match
|
||||||
|
|
||||||
# Assert the template object with the given name is an Active Record descendant and is valid.
|
# Assert the template object with the given name is an Active Record descendant and is valid.
|
||||||
def assert_valid_record(key = nil, message = nil) #:nodoc:
|
def assert_valid_record(key = nil, message = nil) #:nodoc:
|
||||||
@ -150,6 +172,7 @@ def assert_valid_record(key = nil, message = nil) #:nodoc:
|
|||||||
msg = build_message(message, "Active Record is invalid <?>)", record.errors.full_messages)
|
msg = build_message(message, "Active Record is invalid <?>)", record.errors.full_messages)
|
||||||
assert_block(msg) { record.valid? }
|
assert_block(msg) { record.valid? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_valid_record
|
||||||
|
|
||||||
# Assert the template object with the given name is an Active Record descendant and is invalid.
|
# Assert the template object with the given name is an Active Record descendant and is invalid.
|
||||||
def assert_invalid_record(key = nil, message = nil) #:nodoc:
|
def assert_invalid_record(key = nil, message = nil) #:nodoc:
|
||||||
@ -157,6 +180,7 @@ def assert_invalid_record(key = nil, message = nil) #:nodoc:
|
|||||||
msg = build_message(message, "Active Record is valid)")
|
msg = build_message(message, "Active Record is valid)")
|
||||||
assert_block(msg) { !record.valid? }
|
assert_block(msg) { !record.valid? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_invalid_record
|
||||||
|
|
||||||
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid.
|
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid.
|
||||||
def assert_valid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
def assert_valid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
||||||
@ -168,6 +192,7 @@ def assert_valid_column_on_record(key = nil, columns = "", message = nil) #:nodo
|
|||||||
msg = build_message(message, "Active Record has invalid columns <?>)", cols.join(",") )
|
msg = build_message(message, "Active Record has invalid columns <?>)", cols.join(",") )
|
||||||
assert_block(msg) { cols.empty? }
|
assert_block(msg) { cols.empty? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_valid_column_on_record
|
||||||
|
|
||||||
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid.
|
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid.
|
||||||
def assert_invalid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
def assert_invalid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
||||||
@ -179,6 +204,7 @@ def assert_invalid_column_on_record(key = nil, columns = "", message = nil) #:no
|
|||||||
msg = build_message(message, "Active Record has valid columns <?>)", cols.join(",") )
|
msg = build_message(message, "Active Record has valid columns <?>)", cols.join(",") )
|
||||||
assert_block(msg) { cols.empty? }
|
assert_block(msg) { cols.empty? }
|
||||||
end
|
end
|
||||||
|
deprecate :assert_invalid_column_on_record
|
||||||
|
|
||||||
private
|
private
|
||||||
def glue_columns(columns)
|
def glue_columns(columns)
|
||||||
|
Loading…
Reference in New Issue
Block a user