Re: help for learn of XP

"Phlip" <[email protected]> Sat, 10 Mar 2007 13:04:36 -0800
Newsgroups gmane.comp.programming.extreme-programming,gmane.comp.programming.test-first-user-interfaces
Message-ID <00fd01c76357$b6ecb820$6601a8c0@Marley>
Ian Collins wrote:

>>"Ruby on Rails" was invented using most of the XP practices. For example, 
>>it
>>is unique among web development platforms for letting you easily write 
>>unit
>>tests for every aspect of a web application.

> How does it differ form using something like PHPUint and JSUnit?

To answer the OP, those are *Units. Rails is a complete application; an 
example of a project.

The difference with *Units in general is Rails's test framework has 
assertions and systems that match each layer of Rails's web framework. 
Here's a trivial example of submitting a form:

    login_as :ian
    get :index

    submit_form('edit_user') do |form|
      assert_equal '4111111111111118', form['user[cc]'].value
      assert_equal '', form['user[charge]'].value
      form['user[widget]'] = 'widget_3'
    end

    assert_equal 1, @tygr.widgets.count

The first line comes from custom test-side code that logs us into the 
authentication system.

The second line gets the 'index.rhtml' file and processes it as if a web 
browser had sent it. This follows the "Mock the Server" pattern.

index.rhtml has a form that calls the edit_user server action. So the 
submit_form line is an assertion that finds the form, and then simulates 
sending its data

The do-end block can assert the form's variables, and can change them. If 
the form doesn't have a given 'user[field]' input item, by name, the 
assertion will fail. This prevents the degenerate situation where the tests 
send info to the back end that the user interface does not send. The same 
assertion tests the GUI and back-end at the same time.

-- 
  Phlip
  http://www.greencheese.us/ZeekLand <-- NOT a blog!!! 



To Post a message, send it to:   [email protected]

To Unsubscribe, send a blank message to: [email protected]

ad-free courtesy of objectmentor.com