THE THING I LOVE ABOUT RAILS IS THE TESTS
Test are awesome! I've made very risky refactorings, on the fly, and
caught myself with good landings on Rails tests. Testing well around
your Models' APIs let's you feel free to make a healthly-looking
change, even on a hunch that you'll get cleaner results.
Here's a nice one from Grabb.it
def test_metadata_without_override
t = tracks(:happyxmas)
assert_equal 30, t.metadata_level
t.metadata = @full_metadata, :source
assert_equal 30, t.metadata_level
assert_equal "Happy Christmas", t.title
assert_equal "Amysue", t.artist.name
assert_equal @full_metadata[:album], t.albums.first.title
assert_equal @full_metadata[:annotation], t.annotation
end
The @full_metadata test-setup variable holds a complete hash of song
metadata settings. the, :source symbol argument specifies the metadata
input level. Other options are :id3, :music_brainz, and :druid. I'm
experimenting with long local variables here, I tend to use short
variable names in my application code, but I think long names helps
tests to be rigid. I'd rather type md[:title] alot that name the full
metadata hash each time. I'm still learning.
Chris
On 4/21/06, Erik Hollensbe <[EMAIL PROTECTED]> wrote:
>
> On Apr 21, 2006, at 4:11 PM, Sam Livingston-Gray wrote:
>
> > On 4/21/06, Erik Hollensbe <[EMAIL PROTECTED]> wrote:
> >> On Apr 21, 2006, at 3:33 PM, Tim Dysinger wrote:
> >>> Don't get me wrong, I'm committed to finishing the "Agile with RoR"
> >>> book but I miss Java already.
> >>
> >> Then use java.
> >
> > Translation: [http://blog.daveastels.com/articles/2006/04/13/dhh-at-
> > canada-on-rails]
> > ? (=
>
> No. That is certainly not what I'm saying.
>
> What I'm saying is that if Java is working for him, then he should
> use Java. My reply was a very futile attempt to avoid the train of
> comments that was going to happen.
>
> _______________________________________________
> PDXRuby mailing list
> [email protected]
> IRC: #pdx.rb on irc.freenode.net
> http://lists.pdxruby.org/mailman/listinfo/pdxruby
>
--
Chris Anderson
http://musicfordozens.com/jchris
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby