[rspec-devel] [ rspec-Bugs-11231 ] fixtures don't load with before(:all)

noreply at rubyforge.org noreply at rubyforge.org
Wed May 30 10:52:00 EDT 2007


Bugs item #11231, was opened at 2007-05-30 09:52
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11231&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jeremy Stephens (viking415)
Assigned to: Nobody (None)
Summary: fixtures don't load with before(:all)

Initial Comment:
Fixtures only load when using before(:each).  If I use before(:all), they don't get loaded at all.

To reproduce this, run these commands in a shell:

rails -d sqlite3 jungle
cd jungle
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
script/generate rspec
script/generate rspec_model monkey name:string
rake db:migrate


Then edit spec/models/monkey_spec.rb to include the following:
#############
require File.dirname(__FILE__) + '/../spec_helper'

describe "monkey with a before(:each)" do
  fixtures :monkeys

  before(:each) do
    @monkey = Monkey.find_by_id(1)
  end

  it "should not be nil" do
    @monkey.should_not be_nil
  end
end

describe "monkey with a before(:all)" do
  fixtures :monkeys

  before(:all) do
    @monkey = Monkey.find_by_id(1)
  end

  it "should not be nil" do
    @monkey.should_not be_nil
  end
end
#############

Run rake spec:models, and watch the first pass and the second fail.  I'm running Kubuntu (Feisty) with Rails 1.2.3 and RSpec SVN r2060 (1.0.4).

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11231&group_id=797


More information about the rspec-devel mailing list