[rspec-users] fixtures in before(:all)

Geoffrey Wiseman geoffrey.wiseman at gmail.com
Fri Sep 7 15:31:58 EDT 2007

I was planning on using a fixture within a description that didn't modify
the fixture, so I put it in a before(:all) block:

describe "Customer", "xml" do
  fixtures :customers

  before(:all) do
    one = customers(:one)

  # ...

As a result, I got this message:

NoMethodError in 'Customer xml before(:all)'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

If I convert it to before(:each) or simply before, it works just fine.

describe "Customer", "xml" do
  fixtures :customers

  before do
    one = customers(:one)

  # ...

By design?  bug?  PEBKAC?  Anyone else hit this?

   - Geoffrey
Geoffrey Wiseman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070907/82661968/attachment.html 

More information about the rspec-users mailing list