10000 Get access to RenderArgs from tests · Issue #801 · revel/revel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Get access to RenderArgs from tests #801
Open
@ghost

Description

There is such a wonderful thing in Django as response.context. It let access data which has been used for rendering of templates. In case of Revel it could look like:

// app.go (Just usual Revel application which renders something)
func (c *App) Profiles() revel.Result {
    profiles := models.Profiles()
    return c.Render(profiles)
}
// apptest.go
func (t *TestSuite) TestThatProfilesListWorks() {
    t.Get("/app/profiles")
    t.AssertEqual(1, len(t.Response.RenderArgs["profiles"]))
    t.AssertEqual("John Doe", t.Response.RenderArgs["profiles"][0].Fullname)
}

Thus it is possible to better test the correctness of controllers' work. And changes in templates will not break all the tests.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0