[rspec-users] Shoulda

David Chelimsky dchelimsky at gmail.com
Thu Jan 10 19:09:35 EST 2008

On Jan 10, 2008 6:04 PM, Jonathan Leighton <j at jonathanleighton.com> wrote:
> On Thu, 2008-01-10 at 17:59 -0600, David Chelimsky wrote:
> > Another issue is BDD philosophy. BDD is about behaviour. should
> > have_many(:posts) is not behaviour. It is structure. I understand that
> > there are people who view this differently, and I would not want to
> > get in the way of anyone using that approach, but RSpec should not be
> > sporting conveniences, even very pragmatic ones, that fundamentally go
> > against the grain of BDD.
> Out of interest, how would/do you test associations David? What if
> should have_many(:posts) tested the behaviour of the association rather
> than whether it's defined?

It has more to do with what I'm looking at in my specs than what lies
under the hood. Why do I care if a visitor has_many(:posts)? Maybe
there is something different about a blogger with no posts vs one with
50. So I'd have an example:

describe Blogger, "with no posts" do
  it "should be completely lame and banned for eternity" do
    @blogger.should be_completely_lame_and_banned_for_eternity

describe Blogger, "with 1000 posts" do
  it "should be revered by the community" do
    (1..1000).each { @blogger.post(:title => "today's thoughts") }
    @blogger.should be_revered_by_the_community

Now we're talking about behaviour. has_many is implied. No need to
spec it directly - serves no purpose by itself.

That all make sense?

More information about the rspec-users mailing list