The primary difference between -- say -- rSpec and Test::Unit is syntactical. 
However, the specification of how something "should behave" puts you in a 
different frame of mind than testing that something *did* behave that way. 
Consider this:

it "should have 10 records" do
  MyModel.create(:amount => 40.50, :tax_rate => 0.10)
  MyModel.first.tax.should ==(4.50)  # forget, for the moment, floating point 
inaccuracy
end

This is specifying the behavior that a $40.50 purchase taxed at 10% should set 
a "tax" attribute in the model to $4.50. The Test::Unit alternative is to 
assert that this happened. E.g.:

MyModel.create(:amount => 40.50, :tax_rate => 0.10)
assert_equal(4.50, MyModel.first.tax)

Ultimately, you are:

1) Unit testing

and

2) Doing the exact same thing with somewhat different syntax

Personally, I read and write the rSpec syntax more naturally than Test::Unit, 
but it's a matter of taste.

Now, if you go to Cucumber or Rails Integration testing, you are moving away 
from unit testing to more end-to-end behavioral testing. My personal opinion is 
that they are both important for a project of any scale, but writing the 
scenarios for Cuke first and the unit tests to drive the features out is the 
most natural way to do it.

Hope this helps


On Dec 2, 2009, at 11:58 AM, Christoph Jasinski wrote:

> Thanks for the replies.
> 
> I fired that question cause I bought a bunch of BDDCasts from (bddcasts.com) 
> and the first thing they did when bootstrapping the application, was to 
> delete the test folder. So that and the first chapter of the book (mentioned 
> above) got me thinking that bdd replaces unit testing as it is focusing on 
> behaviour which is in total contrast to unit tests which focuses on . Sure, 
> you still could test in both directions but somehow that idea sounded like a 
> lot of work.
> 
> 
> 
> 
> --
> 
> 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 rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.

--

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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to