[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)
  end

  # ...

As a result, I got this message:

1)
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.[]
./spec/models/customer_spec.rb:86:
script/spec:4:

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)
  end

  # ...

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