How to write test case for DataBase search

Hi All

i have written codes to do a database search in my appication using the
mysql fully text search. it works properly.

bt now i have a problem in writing test case for it. so can some body
pls help me how to write testing codes for this database searching
function.

Thanks
Nadeesha

If you have built an application using scaffold then you can easily
modify
database search criteria. Just modify the first line in the controller
script

@myController = myController.find :all

to something like

@mController = myController.find :all, :name => “Controller Name”

This is Ruby for SELECT * FROM my_controllers WHERE name=‘Controller
Name’

If you are new to RoR then you should look at scaffolding to get you up
and
going with your database quickly.

Look at this http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator

hi Matt

Thanks for the tips. bt the case is i need to write the test case for
the functionality in my controller. this controller is written only to
do DB search only. so i need to write a test case codes for it.

def test_public_search_with_data
get :public_search, {}, {:query => “help”}
assert_response 200
end

some what like this . bt the case is this is not working propely. so i
want to know whether the my approach is correct or is their is another
way for this.

Thanks
Nadeesha

Matt Moloney wrote:

If you have built an application using scaffold then you can easily
modify
database search criteria. Just modify the first line in the controller
script

@myController = myController.find :all

to something like

@mController = myController.find :all, :name => “Controller Name”

This is Ruby for SELECT * FROM my_controllers WHERE name=‘Controller
Name’

If you are new to RoR then you should look at scaffolding to get you up
and
going with your database quickly.

Look at this http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs