Home MVC Storefront

Webcast: Unit Testing With Rails

A lot people keep emailing me and letting me know how much they like the Rails webcasts I've been doing so I thought I'd continue today with a webcast all about their Unit Testing framework.

I mention this in the video, but it's worth writing here: I'm not trying to "convert" or sway people - my goal is to show what's out there. Rails has some very very cool stuff that goes into it, and it's built-in unit testing feature is quite cool. Maybe one day we can see something like this in the .NET stack that's part of the framework and not a function of the IDEĀ (no EULA comments please :):):).

This webcast is about 20 minutes long and I show you how to set up Unit Tests, and also some tips and tricks for generating test data using YML.

You can view it here!

Ryan avatar
Ryan says:
Wednesday, August 08, 2007
That's funny...early on SubSonic made me curious about Rails....and now I'm hooked. Thanks Rob!

Zack Owens avatar
Zack Owens says:
Thursday, August 09, 2007
Hmmm.... I see a lot of similarities with Rails and ASP.NET. But very cool stuff.

Haacked avatar
Haacked says:
Thursday, August 09, 2007
Great WebCast Rob! You're inspiring me to make my own. My first one will be entitled "How Rob is like Lindsay Lohan"

Haacked avatar
Haacked says:
Thursday, August 09, 2007
Rob, how about a screencast where you demo common UI implementations the "Rails Way"?

For example, suppose I want to use a dropdown to call a controller action on select. How would I do that?

Rob Conery avatar
Rob Conery says:
Thursday, August 09, 2007
@Phil - thanks :). I had a fun time making it...

In terms of the UI stuff - it's actually very easy. For most things, there's a Rails short cut - for instance, to setup a link to a different page you write:

<%=link_to "link text", :controller => "mycontroller", :action => "myaction"%>

In your case, you might want to wrap your dropdown in a form, and then post the results to a controller. That's pretty simple:

(the form code)
<% form_for :myobject, :url => { :action => :myobject_controller_action } do |form| %>

#now you have a form that is "dedicated" to a model and controller/action set. To create a drop down you can:

<%= collection_select(:myobject, :myobject_foreign_key ,LookupContoller.find(:all), :id, :name) %>

This will load up your dropdown for you.

One thing I needed to get used to was using more than one form - ASP only allows one per page - Rails uses them liberally :).

Rob Conery avatar
Rob Conery says:
Thursday, August 09, 2007
@zack - you see similarities? The only thing similar I see is the <%=%> syntax.

Keep in mind here that the Unit Tests are actually testing your web site - NOT just code behind. It's all the same to the tests which is a Major Leap if you ask me.

Also, forcing the separation of model and functional testing is brilliant :).


Search Me
Subscribe

Popular Posts
 
My Tweets
  • @codinghorror: I may be weird but I don't ask my cats to write my blog entries :p.
  • @blowdart sure! Wanna come on and do a webcast with me - plugging CardSpace in?
  • People are very, very weird. Skypecasts are creepy.
  • Is Rob Howard trying to tell us something? http://www.rob-howard.net/
  • New storefront posted- all about OpenID :) http://tinyurl.com/5rkgux
  About Me



Hi! My name is Rob Conery and I work at Microsoft on the ASP.NET team. I am the Creator of SubSonic and was the Chief Architect of the Commerce Starter Kit (a free, Open Source eCommerce platform for .NET)

I live in Kauai, HI with my family, and when my clients aren't looking, I sometimes write things on my blog (giving away secrets of incalculable value).