Permalink
Browse files

`assert_template` fails with empty string.

  • Loading branch information...
1 parent 20723ca commit 2d6c4ec731861225779f3106f038effb17a27b21 @roberto roberto committed Nov 23, 2012
View
@@ -1,6 +1,6 @@
## Rails 4.0.0 (unreleased) ##
-* `assert_template` is no more passing with empty string when some template has been rendered.
+* `assert_template` is no more passing with empty string.
*Roberto Soares*
@@ -94,14 +94,10 @@ def assert_template(options = {}, message = nil)
matches_template =
case options
when String
- if options.empty?
- rendered.blank?
- else
- rendered.any? do |t, num|
- options_splited = options.split(File::SEPARATOR)
- t_splited = t.split(File::SEPARATOR)
- t_splited.last(options_splited.size) == options_splited
- end
+ !options.empty? && rendered.any? do |t, num|
+ options_splited = options.split(File::SEPARATOR)
+ t_splited = t.split(File::SEPARATOR)
+ t_splited.last(options_splited.size) == options_splited
end
when Regexp
rendered.any? { |t,num| t.match(options) }
@@ -454,6 +454,13 @@ def test_with_empty_string_fails_when_template_rendered
end
end
+ def test_with_empty_string_fails_when_no_template_rendered
+ get :nothing
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template ""
+ end
+ end
+
def test_passes_with_correct_string
get :hello_world
assert_template 'hello_world'

0 comments on commit 2d6c4ec

Please sign in to comment.