Red Squirrel Reflections
Dave Hoover explores the psychology of software development

Dave Hoover
dave.hoover@gmail.com

Categories
All [Atom]
Craftsmanship [Atom]
Dynamic [Atom]
Intersection [Atom]
Learning [Atom]
Links [Atom]
Polyglot [Atom]
Projects [Atom]
XP [Atom]
Old Blog

Obtivian Blogs

Andy Maleh
Colin Harris
Fred Polgardy
Jake Scruggs
Kevin Taylor
Leah Welty-Rieger
Ryan Platte
Todd Webb
Tyler Jennings

Archives

October 2008 (3)
September 2008 (1)
June 2008 (4)
April 2008 (3)
March 2008 (1)
February 2008 (1)
August 2007 (1)
July 2007 (1)
June 2007 (1)
May 2007 (4)
April 2007 (3)
March 2007 (5)
February 2007 (6)
January 2007 (6)
December 2006 (10)
November 2006 (5)
October 2006 (8)
September 2006 (8)
August 2006 (5)
July 2006 (12)
June 2006 (7)
May 2006 (5)
April 2006 (5)
March 2006 (4)
February 2006 (2)
January 2006 (5)
December 2005 (5)
November 2005 (3)
October 2005 (3)
September 2005 (6)
August 2005 (4)
July 2005 (7)
June 2005 (14)
May 2005 (6)
April 2005 (8)
March 2005 (9)
February 2005 (11)
January 2005 (16)
Old Archives

 

Thu, 07 Sep 2006

Watir on Rails Plugin

After showing some hacked up examples of Watir and Rails integration at RailsConf and last Friday's Ajax on Rails addon, I decided that I was way overdue to venture into the exciting world of Rails Plugins. And just a few hours later, Watir on Rails was born.

Here's a quickstart...

  gem install [safari]watir
  ./script/plugin install svn://rubyforge.org/var/svn/watir-on-rails
  ./script/generator watir SuccessfulLogin
  ./script/server -e test
  rake test:watir

One of my goals for this first release was to make Watir on Rails have a similar feel to Rails Integration Tests, which provide a handy open_session method you can use to decorate your session object with a site-specific language. Well, if you know anything about Watir, it should not come as a surprise that Watir on Rails provides an open_browser method that does something similar. You can use open_browser to simply open a browser and use the excellent Watir API, or you can provide an optional block and write Watir on Rails tests methods like this...

  def test_login	
    browser = open_browser
    browser.login_with :username => "dave", :password => "test"
    assert_match /Welcome Dave/, browser.div(:id, "banner").text
  end

  def open_browser
    super do |browser|
      def browser.login_with(args)
        goto("http://localhost:3000/login")
        text_field(:name, "user[name]").set(args[:username])
        password(:name, "user[password]").set(args[:password])
        button(:name, "login").click
      end      
    end
  end

[/projects/watir] permanent link


powered by blosxom