[rspec-users] Preconditions

Geoffrey Wiseman geoffrey.wiseman at gmail.com
Fri Sep 7 17:36:10 EDT 2007

On 9/7/07, Pat Maddox <pergesu at gmail.com> wrote:
> describe MyModel, " when saved twice" do

This is the key point I hadn't considered; makes sense, as long as you make
sure that there's a context wherein the specification that it should have a
certain number of revisions.  Thanks!

Realized this afternoon that I need to use finer-grained 'test methods' than
I'm used to.  In some ways the it blocks are closer to assertions than to
test methods in Test::Unit, in some ways.  So I went from my first crack,
closer to:

describe Customer, "xml" do
  before do
    # set up customer

  it "should generate valid summary xml" do
    # generate summary xml
    # a bunch of shoulds  about the xml

  it "should generate valid full xml" do
    # generate full xml
    # a bunch of shoulds

To something like this:
describe Customer, "full xml" do
  before do
    # set up customer full xml

  it "should have a root node of customer" do
    @doc.root.name.should == 'customer'

  it "should contain a customer id"
  it "should have a name and address"


describe Customer, "summary xml" do
  # etc.

So I guess I'm still learning the mindset in places.  Although you could
ahve test methods like that in Test::Unit, most of the time you wouldn't
bother simply because of the shared setup.  But when the blocks affect how
the spec is described, it's far more important to have fine-grained
elements, I think.

Actually, on that note -- what's the normal way to share a setup across
multiple behaviors, a helper method in an includeable module?

So, thanks for the guidance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/1f0d83ce/attachment.html 

More information about the rspec-users mailing list