Wednesday, September 1, 2010

How to use LibXML on rails

xml_doc =
xml_doc.root ="node_name")
xml_doc.root['id'] = id.to_s
xml_doc.root << xml_ex1 ="ex1")
xml_doc.root << xml_ex2 ="ex2")
#my method to convert an array into a filler of the ex1 node
self.push_this_array_into_this_node(notifications, xml_ex1, "notification")
#my method to convert an array into a filler of the ex2 nodeself.push_this_array_into_this_node(requests, xml_ex2, "request")
return xml_doc

How to start with selenium on Ruby on Rails

script/plugin install

script/generate selenium first.rsel

script/server -e test -p 3001


cookbook for testing on ruby on rails

unit test core methods
setup       -> test initialization
teardown -> test cleanup

How test a unit
ruby test/x_unit.rb

How to test a unit test
ruby test/unit/timesheet_test.rb -n test_x1

How to test controllers
rake test:functionals

How to test models
rake test:units

How to test everything

How to get stats
rake stats

to replicate development schema
rake db:test:prepare

script/plugin install
Once the plugin is installed, dumping a fixture is a simple matter of invoking a new rake task called rake db:fixtures:dump. Unlike the built-in loading rake task, this one takes a MODEL parameter with the name of the ActiveRecord class that you want to dump data for:
$ rake db:fixtures:dump MODEL=BillingCode