Thursday, July 31, 2008

Unit/Functional Testing RubyAMF

One of my current projects is using RubyAMF to communicate with Flash (http://rubyforge.org/projects/rubyamf/). On the whole this is really nice because it allows you to transfer Ruby objects directly to ActionScript ones (as opposed to translating the object into XML, sending the XML and then recreating the object in ActionScript).

However, Rails does not provide a built in transport mechanism for AMF, so we cannot run functional testing directly on the data call (as we could for an XML or HTML transport layer). This is a show stopper for a lot of people (Rails w/o Unit testing = a big mess of trouble when something goes wrong).

We can though serve both the HTML and the AMF formats depending on the request format. This means that we can test the object instantiation logic and make sure there are no errors in the controllers (though we cannot check the actual format of the data being served).

In the controller, instead of rendering AMF alone, do the following

respond_to do |format|
format.html {render :text => ""}
format.amf { render :amf => @photo }
end

Note: You will have to give the variable object instance scope using the @ sign so we can test for it

Then in the unit test file, you can test in the following manner

def test_get_photo
get :get_photo
assert_not_nil assigns(:photo)
assert_response :success
end

So you can at least test that the object got instantiated and no errors were generated.

22 comments:

gFairbrother said...

Hey, good idea was wondering how to test AMF stuff, thanks for sharing.

Anonymous said...

free single dating service [url=http://loveepicentre.com/]singer dating personal[/url] dating is murder by susan jane kozak http://loveepicentre.com/ downloadable simulation dating games

Anonymous said...

medical history of the renaissance [url=http://usadrugstoretoday.com/products/epivir.htm]epivir[/url] putnam community medical center palatke fl http://usadrugstoretoday.com/products/tentex-royal.htm smoking and red blood count http://usadrugstoretoday.com/catalogue/m.htm
virtua health system [url=http://usadrugstoretoday.com/products/dilantin.htm]dilantin[/url] better health store [url=http://usadrugstoretoday.com/products/glyset.htm]vaginal fluids and smells[/url]

Anonymous said...

scandinavian heart [url=http://usadrugstoretoday.com/products/luvox.htm]luvox[/url] penis ring masturbation http://usadrugstoretoday.com/products/buspar.htm canada health act and rhpa http://usadrugstoretoday.com/products/alavert.htm
health insurance company in the us [url=http://usadrugstoretoday.com/products/flagyl-er.htm]flagyl er[/url] carbohydrates in apples [url=http://usadrugstoretoday.com/products/revia.htm]holiday tea receipt[/url]

Anonymous said...

http://healthboard.in/calcium/hormones-calcium-concentration
[url=http://healthboard.in/calcium/folia-calcium-turf]bare metal stents vs drug eluting[/url] drugs street name surfs [url=http://healthboard.in/brahmi/brahmi-oil]brahmi oil[/url]
pharmacy training program versus no training http://healthboard.in/crestor/crestor-problem
[url=http://healthboard.in/caffeine/long-term-effects-of-caffeine]information about the drug trazodone[/url] generic pharmacy online complaints [url=http://healthboard.in/conjugated-linoleic-acid/side-effects-conjugated-linoleic-acid]side effects conjugated linoleic acid[/url]
effects of drugs on pregnancy http://healthboard.in/carafate/carafate
[url=http://healthboard.in/crestor/blog-crestor-for-websites]full information levitra[/url] employment pharmacy [url=http://healthboard.in/bupropion/canadian-bupropion-hcl-prescription]canadian bupropion hcl prescription[/url] high pharmacy [url=http://healthboard.in/bupropion/bupropion-price]bupropion price[/url]

Anonymous said...

http://alwayshealth.in/olanzapine/olanzapine-and-weight-gain
[url=http://alwayshealth.in/pill/pill-s]meridia pharmacy low prices[/url] olanzapine drug [url=http://alwayshealth.in/man-health/health-magazine-man-model]health magazine man model[/url]
verapamil drug interaction s http://alwayshealth.in/medical-encyclopedia/journal-of-medical-internet-research-online-consumer-surveys
[url=http://alwayshealth.in/no-prescription/amoxicillin-zyrtec-no-prescription-required-viagra]drugs that make u voice deeper[/url] cialis comparison diflucan viagra [url=http://alwayshealth.in/pravachol/of-pravachol]of pravachol[/url]
fda fee new drug http://alwayshealth.in/prescription/hydrocodone-15-mg-no-prescription
[url=http://alwayshealth.in/omeprazole/omeprazole-cap]wacker drug trial kansas boyle[/url] drug information on prednizone [url=http://alwayshealth.in/pharmacy/pharmacy-technician-continuing-eduaction]pharmacy technician continuing eduaction[/url] clinical pharmacy software [url=http://alwayshealth.in/pain-relief/pain-relief-medication-for-tooth-abscess]pain relief medication for tooth abscess[/url]

Anonymous said...

boat travel members alberta http://livetravel.in/disneyland/cheap-disneyland-paris-passes find cheap travel insurance
[url=http://livetravel.in/cruise/cruise-pricing]travel western caribbean[/url] alabama travel baseball teams [url=http://livetravel.in/tourism/harayana-tourism]harayana tourism[/url]
how many miles per hour can a plane travel http://livetravel.in/lufthansa/boeing-versus-airbus
[url=http://livetravel.in/plane-tickets]futura travel mugs[/url] saga travel money [url=http://livetravel.in/disneyland/best-day-to-visit-disneyland]best day to visit disneyland[/url]
travel vail co http://livetravel.in/tours/pride-and-prejeduce-tours
[url=http://livetravel.in/car-rental/letalie-car-rental]travel mpls to las vegas[/url] the travel market [url=http://livetravel.in/plane-tickets/military-discount-for-plane-tickets]military discount for plane tickets[/url] travel value rewards program [url=http://livetravel.in/cruise/norweigian-cruise-jobs]norweigian cruise jobs[/url]
overseas travel allowance south africa [url=http://livetravel.in/lufthansa/boeing-vs-airbus]boeing vs airbus[/url]
travel agents in korea http://livetravel.in/airport/allegiant-phoenix-mesa-airport
[url=http://livetravel.in/tours/western-grand-canyon-tours]travel guatamala[/url] everest travel trailers [url=http://livetravel.in/inn/holiday-inn-express-in-wilmington2c-nc]holiday inn express in wilmington2c nc[/url]
[url=http://livetravel.in/expedia/discount-travel-online-booking-cheap-airfare-expedia-flights]discount travel online booking cheap airfare expedia flights[/url] india travel blogs [url=http://livetravel.in/tours/jamestown-pocahontas-tours]jamestown pocahontas tours[/url] liberrty travel [url=http://livetravel.in/flight/guitar-amp-flight-case]guitar amp flight case[/url]
canadian travel insurance for travelling to south america [url=http://livetravel.in/inn/baricelli-inn]baricelli inn[/url]

Anonymous said...

travel show hosts http://atravel.in/motel_pennsylvania-motel-voucher travel costa raica
[url=http://atravel.in/adventure_littlest-pet-shop-biggest-adventure-tv-plug-in]outback 27 rsd travel trailer[/url] dushi travel [url=http://atravel.in/car-rental_alamo-car-rental-pie]alamo car rental pie[/url]
tuscany passport travel wallet http://atravel.in/map_download-il-quadrangle-map
[url=http://atravel.in/vacation-packages_fiji-vacation-packages]video game storage multisystem travel[/url] job novica opening travel [url=http://atravel.in/tour_garth-brooks-come-tour]garth brooks come tour[/url]
mitylite travel trailer http://atravel.in/cruises_captain-cook-cruises mexico rv travel paul alton [url=http://atravel.in/plane-tickets_plane-tickets-to-anchorage]plane tickets to anchorage[/url]

Anonymous said...

replica prada shoes http://topcitystyle.com/black-dolce-amp-gabbana-color2.html lebanon fashion clothing [url=http://topcitystyle.com/-shirts-with-colar-on-sale-category22.html]anne taylor clothes[/url] man made clothes
http://topcitystyle.com/xxl-women-size8.html women golf shoes [url=http://topcitystyle.com/l-with-hood-size7.html]running shoes reviews runners world[/url]

Anonymous said...

womens fitness shoes http://topcitystyle.com/?action=products&product_id=2453 designer factory outlet uk [url=http://topcitystyle.com/xl-classic-size6.html]fashion show games[/url] infant clothes
http://topcitystyle.com/blumarine-tank-tops-brand53.html womens stylish wide width shoes [url=http://topcitystyle.com/?action=products&product_id=993]soccer turf shoes[/url]

Anonymous said...

buy gucci watcg http://topcitystyle.com/purple-dresses-color37.html best ever designer foundations [url=http://topcitystyle.com/belts-gucci-category42.html]corporate interior designers[/url] grphic designers
http://topcitystyle.com/brown-white-armani-color157.html sexy designer mayernity [url=http://topcitystyle.com/killah-women-apos-s-long-sleeve-tops-brand24.html]new balance shoes[/url]

Anonymous said...

sexy bikini bride http://theporncollection.in/gay-movie/gay-masturbation-trailers
[url=http://theporncollection.in/lubricant/lubricant-lead]huge dildo buy[/url] dildo cam [url=http://theporncollection.in/mature-xxx/massive-cock-mature]massive cock mature[/url]
xxx sexy tits http://theporncollection.in/sex-mature/curvy-mature-in-corset
[url=http://theporncollection.in/gay-man/gay-marie-eskaton]xxx leather crotchless[/url] dildo bobbleheads [url=http://theporncollection.in/lesbian-porn/adult-lesbian-sex-storier]adult lesbian sex storier[/url]
sexy longjohns http://theporncollection.in/hentai-sex/free-hentai-amv
[url=http://theporncollection.in/gay-boy/victoria-gay-men]pink silicone lubricant[/url] jerking dicks off with lubricant [url=http://theporncollection.in/gay-video/tom-selleck-gay]tom selleck gay[/url]
amateur girlfriend porn http://theporncollection.in/gay-movie/private-for-gay
[url=http://theporncollection.in/mature-xxx/free-mature-galleries-mature-galleries]mature amateur nude gallery[/url] xxx massages [url=http://theporncollection.in/porn-dvd/gang-band-porn]gang band porn[/url]

Anonymous said...

cheap travel exotic http://xwa.in/airline/singapore-airline-flight-37 mti travel
[url=http://xwa.in/airline/plane-ticketsdiscount-airline-flight]how many hours did it take santa to travel around the world[/url] venice italy travel guide [url=http://xwa.in/hotel/hotel-maison-140-los-angeles]hotel maison 140 los angeles[/url]
toddler travel n trundle http://xwa.in/car-rental/ft-wayne-dollar-car-rental
[url=http://xwa.in/expedia/expedia-uk]travel channel extreme christmas[/url] macbeth travel scotland [url=http://xwa.in/tour/new-stadium-tour-yankee-york-htm]new stadium tour yankee york htm[/url]
travel lodge at bournemouth uk http://xwa.in/airline/plane-ticketsdiscount-airline-flight travel sites to go in the country of oman [url=http://xwa.in/airport/dulles-airport-weather-report-status]dulles airport weather report status[/url]

Anonymous said...

mens health extenze [url=http://usadrugstoretoday.com/products/prinivil.htm]prinivil[/url] top 10 drug rehabilatation centers http://usadrugstoretoday.com/products/cystone.htm
technology and health [url=http://usadrugstoretoday.com/categories/anti-saure.htm]anti saure[/url] teen weight loss eating plan [url=http://usadrugstoretoday.com/products/remeron.htm ]india producers generic hiv drugs [/url] duke study stored blood heart attacks
city of medical lake [url=http://usadrugstoretoday.com/products/prandin.htm]prandin[/url] cosmetic dental surgery tampa http://usadrugstoretoday.com/catalogue/t.htm
smoking turkey in a brinkman smoker [url=http://usadrugstoretoday.com/categories/cholesterol.htm]cholesterol[/url] aetna aarp health plan [url=http://usadrugstoretoday.com/products/uroxatral.htm ]what is drug compounding [/url] breast canser prevention

Anonymous said...

double vaginal double anal [url=http://usadrugstoretoday.com/products/tetracycline.htm]tetracycline[/url] bacteria and neutrophils http://usadrugstoretoday.com/catalogue/z.htm
borgess health [url=http://usadrugstoretoday.com/products/himcolin.htm]himcolin[/url] altamonte springs fl health insurance [url=http://usadrugstoretoday.com/categories/anti-diabetische.htm ]allegra d effects [/url] california controlled substance prescription laws
wuyi weight loss [url=http://usadrugstoretoday.com/products/prometrium.htm]prometrium[/url] ohio ballot issues 2007 november smoking http://usadrugstoretoday.com/catalogue/h.htm
irvine breast implants [url=http://usadrugstoretoday.com/products/pro-erex.htm]pro erex[/url] board of registry in medicine massachusetts [url=http://usadrugstoretoday.com/bestsellers.htm ]teds tea shop [/url] drug counselor training tx

Anonymous said...

childrens high heeled shoes http://www.thefashionhouse.us/men-page66.html clothes for large men uk [url=http://www.thefashionhouse.us/black-white-color64.html]kleines glied und kleine eier[/url] dark brown baby dress shoes
http://www.thefashionhouse.us/black-and-blue-men-color142.html gothic clothes [url=http://www.thefashionhouse.us/orange-men-color121.html]interior designers bristol[/url]

Anonymous said...

plastic surgery vaginal sculpting [url=http://usadrugstoretoday.com/products/stress-relief.htm]stress relief[/url] journal articles bulling and mental health issues in australia http://usadrugstoretoday.com/products/atacand.htm
expired codeine cough medicine [url=http://usadrugstoretoday.com/categories/erektile-dysfunktion.htm]erektile dysfunktion[/url] penis diet [url=http://usadrugstoretoday.com/categories/gastrointestinales.htm ]buy tea tree lotion for horses [/url] molecule stress ball
blood pressure and illness [url=http://usadrugstoretoday.com/products/quibron-t.htm]quibron t[/url] depression after flu http://usadrugstoretoday.com/products/cordarone.htm
calcium oxalate stones diet [url=http://usadrugstoretoday.com/products/hoodia-weight-loss-gum.htm]hoodia weight loss gum[/url] weight loss patch casino online [url=http://usadrugstoretoday.com/categories/erektile-dysfunktion.htm ]health beliefs of austrlians [/url] breads to eat to lower cholesterol

Anonymous said...

szilvia lauren http://www.thefashionhouse.us/men-page53.html gucci positano [url=http://www.thefashionhouse.us/outwear-page3.html]rhyme for tying shoes[/url] allan fusser clothes
http://www.thefashionhouse.us/?action=products&product_id=1989 working conditions for being a fashion designer [url=http://www.thefashionhouse.us/white-sky-blue-brown-color173.html]designer picture frames[/url]

Anonymous said...

australian goth clothes http://luxefashion.us/yellow-casual-tops-color44.html hsn and shoes off [url=http://luxefashion.us/pullover-page3.html]web designers derby[/url] free business card designer
http://luxefashion.us/m-roberto-cavalli-size5.html journey shoes [url=http://luxefashion.us/36-new-size14.html]next clothes[/url]

Anonymous said...

card high counting blackjack player system deck lot http://wqm.in/roulette_bicycle-casino-swifte-blackjack-poker-baccarat-roulette-bonus recognise gambling in spouses
[url=http://wqm.in/jokers_easy-to-draw-jokers]nortrh carolina lottery[/url] wife wins lottery then divorces [url=http://wqm.in/online-casinos_online-casinos-that-have-the-game-doctor-lovemore]online casinos that have the game doctor lovemore[/url]
kickapoo traditional tribe of texas lucky eagle casino http://wqm.in/betting_atlantic-city-horse-racing-betting
[url=http://wqm.in/joker_mego-joker-mobile]couer d alene casino[/url] free betting tips [url=http://wqm.in/slot_slot-machine-computer-game]slot machine computer game[/url]
royal bingo http://wqm.in/casino-online_hoyle-casino-2008-patch effexor gambling [url=http://wqm.in/baccarat_gratis-baccarat]gratis baccarat[/url]

Anonymous said...

articles on automobile monitoring using gsm http://xwm.in/radiator/fireplace-radiator-fan mercedes 550 s
[url=http://xwm.in/honda/honda-atv-school-escalon]arca sim racing video framerates[/url] auto loan pre approval [url=http://xwm.in/honda/sohc-honda]sohc honda[/url]
arctic cat racing snowmobiles for sale http://xwm.in/pontiac/programming-a-keyless-remote-pontiac-montana-03
[url=http://xwm.in/daihatsu/daihatsu-cuore-review]how many people are killed in automobile accidents in the us[/url] automobile sale prices [url=http://xwm.in/saab]saab[/url]
auto engine oil drain http://xwm.in/citroen/size-of-citroen-c2
[url=http://xwm.in/oldsmobile/water-pump-1967-oldsmobile-toronado]ford remote automobile starter[/url] dodge intrepide [url=http://xwm.in/citroen/citroen-c2-audio-system]citroen c2 audio system[/url]

Anonymous said...

celebrity golf outing luncheon bingo smith http://lwv.in/jackpot/how-can-i-watch-video-of-nash-bridges-season-5-jackpot to play blackjack free
[url=http://lwv.in/blackjack/boris-on-blackjack]menominee casino bingo and hotel keshena wi[/url] average number of blackjack hands dealt per hour [url=http://lwv.in/jackpot/how-can-i-watch-video-of-nash-bridges-season-5-jackpot]how can i watch video of nash bridges season 5 jackpot[/url]
bingo palace http://lwv.in/keno/rules-of-keno-internet
[url=http://lwv.in/baccarat/baccarat-casino]green valley casino las vegas[/url] final betting results for super bowl xlii [url=http://lwv.in/baccarat/cognac-baccarat]cognac baccarat[/url]
teresa ireland bingo http://lwv.in/online-casino/negative-effects-of-builing-a-casino mirage casino and las vegas and swarovsky [url=http://lwv.in/bingo/printable-bingo-money]printable bingo money[/url]