[rspec-users] The distinctive smell of newbiness

Martin Streicher martin.streicher at gmail.com
Wed Sep 17 19:34:50 EDT 2008


The heart of my question is the seemingly chicken-and-egg-like nature  
of testing many models that work together. I now have two flavors of  
tests: tests that keep the models honest (computations and returns  
values are consistent and accurate) and tests that operate at the  
macro level as you suggest. All in all, I am pretty happy with the BDD  
stuff, as I am finding edge cases and bugs, and I have some baseline  
to fall back on when I go ripping out code.

If there are more suggestions about interoperable model testing,  
please send.

On Sep 17, 2008, at 7:14 PM, rspec-users-request at rubyforge.org wrote:

> "Testing a model" or "testing a relationship" doesn't mean much (it
> can mean anything). I recommend you focus your testing efforts on the
> desired *behaviour* of your system, not its implementation. This is a
> very central tenet of BDD.
>
> If your Message class doesn't have any behaviour (code in addition to
> the relationships) there isn't really much about it to test. You
> should assume ActiveRecord works.
>
> I suppose those relationships are there for a reason. Some other code
> uses these relationships. What is that code? Start by testing that
> code. This code is probably on the "outside" of your model, i.e. it
> depends on your model. Typically a controller and/or a view - probably
> both.
>
> Nowadays I usually recommend people start by writing a test for the
> system as seen from the outside. This is called "outside in" and is
> what you'd use Cucumber or the story runner for. Or if you don't use
> it, at least write some kind of end to end test. Then, when you
> discover edge cases, drop down to a lower level (specs that talk to
> the model).
>
> I have a feeling I might have confused you more than helped you. Maybe
> you can explain a little more about what the system's behaviour? It
> would help set the context so we can recommend a good practice ;-)



More information about the rspec-users mailing list