[rspec-users] Wiki -> RSpec -> Watir

Phlip phlip2005 at gmail.com
Tue Nov 7 11:37:11 EST 2006

Rubies & Acceptance Testers:

For those of you not doing acceptance tests yet, I have a very slick test 
rig to show off. I haven't demo-ized it yet, so please accept these diverse 
audiovisual displays as if they were a united whole!

We start with MiniRubyWiki, at this demo:


Click on any of the green bars.

Now imagine if the left graphic were a thumbnail of a screenshot of a web 
page. You could click on the thumbnail and get the complete screenshot. This 
would be a copy of the tested website, in its tested state, with its 
intermediate data.

To drive that test, in the right panel I put RSpec and Watir. So the code to 
log into a website would look like this:

    input_text 'login', 'quentin'
    input_text 'password', 'test'
    click_button 'commit'
    @browser.should_contain('Logged in successfully')
    @browser.should_contain('greetings quentin')

The point of RSpec is syntactic sugar, and I have not yet learned how much 
sweeter I can make that. So far, I have learned how to use it to make 
well-formed English sentences (modulo all the _() delimiter crap!).

Writing acceptance tests with this system is just plain fun. Click one of 
the quill icons next to the green bars.

Before or after I write a new feature, I find a similar test and clone it. 
(Cloning a test is a best-practice in Acceptance Test land, so long as you 
frequently merge things back into features!) Then I edit the new test to 
advance its behavior.

The test cases all go into an XML file (_not_ a Wiki file!). At test time, 
Wiki calls a test runner to run one case in that file. The test runner 
without arguments runs all the cases in all the relevant XML files. It 
stitches together the RSpec environment, tests all the cases, and then 
changes each case's result_color to reflect its passing state.

What feature should I add next?

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

More information about the rspec-users mailing list