Test Spec On Rails plugin

Plugin details

This plugin contain some helpers to test your Rails app using test/spec.

Repositoryhttp://svn.techno-weenie.net/projects/plugins/test_spec_on_rails/ Author Per Wigren Tags Test LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/test_spec_on_rails/

Model validation
----------------

  @user.should.validate
  @user.should.not.validate


or:

  @user.should.be.validated
  @user.should.not.be.validated



Redirection
-----------

  response.should.be.redirected           # assert_response :redirect
  response.should.redirect foo_url(@foo)  # assert_redirected_to foo_url(@foo)
  should.redirect_to :action => 'show'    # because "response" is optional


It's aliased as redirect, redirect_to, redirected and redirected_to


Output verification
-------------------
Wrapper for assert_select:

  get :show
  page.should.select "form#user_form"             # require the output to have a 
  
  page.should.select "form#user_form" do |form|
    form.should.select "input[type=submit]"       # the user_form must include a 
  end



HTTP Status
-----------
Wrapper for assert_response:

  status.should.be :success
  status.should.be 200



Which template was rendered?
----------------------------
Wrapper for assert_template:

  template.should.be "foo/show.rhtml"



URL testing
-----------

  get :show, :user_id => 1
  url.should.be "/users/1"
  url.should.be :controller => "users", :action => "show", :user_id => 1

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 11 months ago