teamon

  • Archive
  • RSS
  • Ask me anything

Webapp testing with Webrat and [your language]

Webrat was written mainly to improve Rails` web applications testing. But what if webapp is written in something else? The answer is simple - webrat!

Requirements: Ruby

Installation: gem install mechanize webrat Done.

Now create file test.rb and put in there:

To run tests use command: spec test.rb
For colorful and more readable output use: spec --color --format specdoc test.rb

That`s almost all. While it works pretty well having all tests in one file is not what we are used to after working with Rails. Let`s fix that by splitting that code into spec_helper.rb and login_spec.rb files.

simple Rakefile for running all tests

and spec.opts

Now you can run test with rake spec command. Note that files with tests must end with _spec.rb in order to get executed by spec command.

Textmate integration

It is possible to run specs from Textmate via ruby-rspec bundle. Just clone repository, double click on ruby-rspec.bundle, open test file and press ⌘ + R to get something like:

    • #testing
  • 2 years ago
  • Comments
  • Permalink
  • Share
    Tweet

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Ruby, Scala and others.

Pages

  • About
  • Projects
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr