Add root in DSL

This commit is contained in:
ccocchi 2012-09-19 17:36:57 +02:00
parent 9f0a92ecd7
commit a97a8cd24f
3 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# CHANGELOG
## 0.2.0 (unrelased)
* Add `root` in DSL to set root without changing the source
* Add XML renderer
* Use MultiJson's preferred JSON engine as default (shmeltex)
* Default template to render with responder can be set per controller

View File

@ -30,6 +30,10 @@ module RablRails
end
alias_method :collection, :object
def root(name)
@template.root_name = name
end
#
# Includes the attribute or method in the output
# Example:

View File

@ -24,6 +24,16 @@ class CompilerTest < ActiveSupport::TestCase
assert_equal({}, t.source)
end
test "root can be defined via keyword" do
t = @compiler.compile_source(%{ root :author })
assert_equal :author, t.root_name
end
test "root keyword override object root" do
t = @compiler.compile_source(%{ object :@user ; root :author })
assert_equal :author, t.root_name
end
test "collection set the data for the template" do
t = @compiler.compile_source(%{ collection :@user })
assert_equal :@user, t.data