Chapter 15. Testing Functions
To access these functions, include Web::Testing in your testcase
require 'web/testing'
require 'web/unit/testcase'
class MyWebTest << Test::Unit::TestCase
include Web::Testing
#...
end
- do_request( scriptname, params={} )
Do a mock request to scriptname, passing in params.
scriptname can be /absolute/scriptname.rb if you use set
the docroot using Web::docroot = "...".
Otherwise, use a relative path from the current directory.
params is a hash of request parameters. You can mock
enviroment parameters on an :env key.
- do_submit( formname, params={} )
-
Once you've done a request, you can submit forms on the page.
You can "fill out" fields by passing in params.
- assert_content(expected, message="")
-
fails if content is not set to the provided string.
- assert_form_includes(formname, vars)
-
Assert output content contains a form that includes the given hash of values. ### this could sure use some more docs.
- Web::get_content()
-
the body content of the response (sans headers)
- assert_header( name, values, message="" )
-
Fails if the header has not been set to the provided value(s).
- assert_cookie( name, values, message="" )
-
Fails if cookie values are not present.