Assert Select plugin

Plugin details

Adds the assert_select method for use in Rails functional tests. Simplifies content testing using CSS selectors.

Websitehttp://blog.labnotes.org/2006/07/03/assert_select-plugin-for-rails/ Repositoryhttp://labnotes.org/svn/public/ruby/rails_plugins/assert_select/ Author Assaf Arkin Tags assert, select LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/

Examples

  # At least one form element
  assert_select "form"
            
  # Form element includes four input fields
  assert_select "form input", 4
       
  # Page title is "Welcome"
  assert_select "title", "Welcome"
            
  # Page title is "Welcome" and there is only one title element
  assert_select "title", {:count=>1, :text=>"Welcome"},
    "Wrong title or more than one title element"
            
  # Page contains no forms
  assert_select "form", false, "This page must contain no forms"
            
  # Test the content and style
  assert_select "body div.header ul.menu"
            
  # All input fields in the form have a name
  assert_select "form input" do |elements|
    elements.each do |element|
      assert not element.attributes["name"].empty?
    end
  end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, 9 months ago