Difference between revisions of "Emergent Web Technologies Spring 2009 Class 12"

esse quam videri
Jump to: navigation, search
(New page: == Introduction == == Activity 1 == This activity uses the testing framework that comes with a standard Ruby on Rails installation. The Ruby on Rails community (and the Ruby community i...)
 
Line 5: Line 5:
  
 
This activity uses the testing framework that comes with a standard Ruby on Rails installation. The Ruby on Rails community (and the Ruby community in general) are very enthusiastic about testing.
 
This activity uses the testing framework that comes with a standard Ruby on Rails installation. The Ruby on Rails community (and the Ruby community in general) are very enthusiastic about testing.
 +
 +
 +
'''1''' First, open up the Instant Rails console and create an application for testing by running the following commands
 +
  rails testing_app
 +
  cd testing_app
 +
  ruby script/generate scaffold Location name:string address:string city:string state:string zip:string
 +
  rake db:migrate
 +
 +
Before testing, you'll also need to set up the testing database by running the following commands
 +
  rake db:migrate
 +
  rake db:test:load
 +
 +
'''2''' The scaffold command automatically generated some tests for your application. We'll be looking at the unit tests for the '''location''' model.
 +
 +
First, make sure that the generated tests are working. This will verify that your scaffolded project has been set up correctly.
 +
  cd test
 +
  ruby unit/location_test.rb
 +
 +
If everything worked correctly, you should see a message that looks like this
 +
  Started
 +
  .
 +
  Finished in 0.25 seconds.
 +
 
 +
  1 tests, 1 assertions, 0 failures, 0 errors
  
  

Revision as of 21:00, 29 April 2009

Introduction

Activity 1

This activity uses the testing framework that comes with a standard Ruby on Rails installation. The Ruby on Rails community (and the Ruby community in general) are very enthusiastic about testing.


1 First, open up the Instant Rails console and create an application for testing by running the following commands

 rails testing_app
 cd testing_app
 ruby script/generate scaffold Location name:string address:string city:string state:string zip:string
 rake db:migrate

Before testing, you'll also need to set up the testing database by running the following commands

 rake db:migrate
 rake db:test:load 

2 The scaffold command automatically generated some tests for your application. We'll be looking at the unit tests for the location model.

First, make sure that the generated tests are working. This will verify that your scaffolded project has been set up correctly.

 cd test
 ruby unit/location_test.rb

If everything worked correctly, you should see a message that looks like this

 Started
 .
 Finished in 0.25 seconds.
 
 1 tests, 1 assertions, 0 failures, 0 errors


Activity 2

This activity uses the Screw.Unit JavaScript testing framework. This is a simple and easy to use framework and, despite the name, it actually works pretty well.

Activity 3

This activity uses the Watir framework to remotely control your browser.