On Apr 16, 9:37 am, Phlip <[email protected]> wrote:
> Joshua Muheim wrote:
[...]
> >   def setup
> >     @valid_blog = Blog.new(valid_blog_attributes)
>
> Don't construct a blog - fetch one from the fixtures:
>
>       �...@valid_blog = blogs(:valid_blog)

Why?  In my experience, fixtures make tests brittle and hard to
understand, so I've stopped using them entirely.  What's the advantage
here?

[...]
> As you get better at testing, you will get bored with testing that 
> ActiveRecord
> behaves as advertised, and you will test your actual logic.

Yeah.  ActiveRecord has already been well tested.  Focus on the code
you wrote.

(I know, that's a tough concept to internalize -- I certainly don't
always manage...)

>
> To set a good example here, don't test against nil, because if comments were 
> an
> empty array, then assert_not_nil [] would pass.
>
> Instead, test that the comment went in:
>
>          assert{ @valid_blog.comments.last == comment }
>
> That illustrates two things. It shows my assert{ 2.0 }, which turns any
> expression into a generic assertion,
[...]

Cool!  Sexy RSpecish syntax for the unsexy Test::Unit!  I'll have to
try it out!  :P

(Seriously, I think assert2 looks great, and I'm looking forward to
trying it.)

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to