response_from_page

response_from_page() Instance Protected methods assert_select and css_select call this to obtain the content in the HTML page.

css_select

css_select(*args) Instance Public methods Select and return all matching elements. If called with a single argument, uses that argument as a selector to match all elements of the current page. Returns an empty array if no match is found. If called with two arguments, uses the first argument as the base element and the second argument as the selector. Attempts to match the base element and any of its children. Returns an empty array if no match is found. The selector may be a CSS se

assert_select_encoded

assert_select_encoded(element = nil, &block) Instance Public methods Extracts the content of an element, treats it as encoded HTML and runs nested assertion on it. You typically call this method within another assertion to operate on all currently selected elements. You can also pass an element or array of elements. The content of each element is un-encoded, and wrapped in the root element encoded. It then calls the block with all un-encoded elements. # Selects all bold tags fr

assert_select_email

assert_select_email(&block) Instance Public methods Extracts the body of an email and runs nested assertions on it. You must enable deliveries for this assertion to work, use: ActionMailer::Base.perform_deliveries = true assert_select_email do assert_select "h1", "Email alert" end assert_select_email do items = assert_select "ol>li" items.each do # Work with items here... end end

assert_select

assert_select(*args, &block) Instance Public methods An assertion that selects elements and makes one or more equality tests. If the first argument is an element, selects all matching elements starting from (and including) that element and all its children in depth-first order. If no element if specified, calling assert_select selects from the response HTML unless assert_select is called from within an assert_select block. When called with a block assert_select passes an array

with_routing

with_routing() Instance Public methods A helper to make it easier to test different route configurations. This method temporarily replaces @routes with a new RouteSet instance. The new instance is yielded to the passed block. Typically the block will create some routes using set.draw { match ... }: with_routing do |set| set.draw do resources :users end assert_equal "/users", users_path end

method_missing

method_missing(selector, *args, &block) Instance Public methods ROUTES TODO: These assertions should really work in an integration context

assert_routing

assert_routing(path, options, defaults={}, extras={}, message=nil) Instance Public methods Asserts that path and options match both ways; in other words, it verifies that path generates options and then that options generates path. This essentially combines assert_recognizes and assert_generates into one step. The extras hash allows you to specify options that would normally be provided as a query string to the action. The message parameter allows you to specify a custom error mess

assert_recognizes

assert_recognizes(expected_options, path, extras={}, msg=nil) Instance Public methods Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options. Pass a hash in the second argument (path) to specify the request method. This is useful for routes requiring a specific HTTP method. The hash should contain a :path with the inc

assert_generates

assert_generates(expected_path, options, defaults={}, extras={}, message=nil) Instance Public methods Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures. The defaults parameter is unused. # As