Skip to content

Commit

Permalink
assert_template: validating option keys
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto committed Nov 26, 2012
1 parent 4d0dc53 commit 3f2c011
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion actionpack/CHANGELOG.md
@@ -1,6 +1,8 @@
## Rails 4.0.0 (unreleased) ##

* `assert_template` is no more passing with empty string.
* `assert_template`:
- is no more passing with empty string.
- is now validating option keys. It accepts: `:layout`, `:partial`, `:locals` and `:count`.

*Roberto Soares*

Expand Down
2 changes: 2 additions & 0 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -106,6 +106,8 @@ def assert_template(options = {}, message = nil)
end
assert matches_template, msg
when Hash
options.assert_valid_keys(:layout, :partial, :locals, :count)

if options.key?(:layout)
expected_layout = options[:layout]
msg = message || sprintf("expecting layout <%s> but action rendered <%s>",
Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/controller/action_pack_assertions_test.rb
Expand Up @@ -430,6 +430,12 @@ def test_assert_response_failure_response_with_no_exception
class AssertTemplateTest < ActionController::TestCase
tests ActionPackAssertionsController

def test_with_invalid_hash_keys_raises_argument_error
assert_raise(ArgumentError) do
assert_template foo: "bar"
end
end

def test_with_partial
get :partial
assert_template :partial => '_partial'
Expand Down

0 comments on commit 3f2c011

Please sign in to comment.