[rspec-users] Error against latest trunk while testing via spec for model

Deepak Jois deepak.jois at gmail.com
Thu Feb 15 01:25:06 EST 2007


> The error seems to be related to loading the fixture because other
> specs not related to specs pass as normal.
>

Ok I know the cause of the error now. It is because the fixtures path
is not being passed correctly.

turns out that my spec_helper file was outdated, here is a diff. Hope it helps

Index: spec/spec_helper.rb
===================================================================
--- spec/spec_helper.rb (revision 134)
+++ spec/spec_helper.rb (working copy)
@@ -1,6 +1,6 @@
 # This file is copied to ~/spec when you run 'ruby script/generate rspec'
 # from the project root directory.
-ENV["RAILS_ENV"] = "test"
+ENV["RAILS_ENV"] ||= "test"
 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
 require 'spec/rails'

@@ -10,15 +10,17 @@
 # tightly coupled to Test::Unit in Rails, which is why you're seeing it here.
 module Spec
   module Rails
-    class EvalContext < Test::Unit::TestCase
-      self.use_transactional_fixtures = true
-      self.use_instantiated_fixtures  = false
-      self.fixture_path = RAILS_ROOT + '/spec/fixtures'
+    module Runner
+      class EvalContext < Test::Unit::TestCase
+        self.use_transactional_fixtures = true
+        self.use_instantiated_fixtures  = false
+        self.fixture_path = RAILS_ROOT + '/spec/fixtures'

-      # You can set up your global fixtures here, or you
-      # can do it in individual contexts using "fixtures :table_a, table_b".
-      #
-      #self.global_fixtures = :table_a, :table_b
+        # You can set up your global fixtures here, or you
+        # can do it in individual contexts using "fixtures :table_a, table_b".
+        #
+        #self.global_fixtures = :table_a, :table_b
+      end
     end
   end
 end


More information about the rspec-users mailing list