[rspec-users] Problem running RSpec tests with Rails

Ashley Moran ashley.moran at patchspace.co.uk
Mon Jul 26 12:50:05 EDT 2010


On Jul 26, 2010, at 5:12 pm, Bruno Cardoso wrote:

> Not sure if this is a RSpec problem or Rails but I believe is more a
> RSpec situation.
> 
> What happens is that when I run my RSpecs tests all the BD is recreated,
> 
> ...
> 
> Anyone know how to resolve this?

Hi Bruno

Are you running `rake spec` as opposed to the spec command?  The default Rails spec task depends on the "db:test:prepare" task, which bombs your DB.  I fixed this in my project with a file "lib/tasks/rspec_fixes.rake":

  class Rake::Task
    def overwrite(&block)
      @actions.clear
      enhance(&block)
    end
  end

  Rake::Task['db:test:prepare'].overwrite do
    # We don't want to run migrations or load the schema!!!
  end

HTH

Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran



More information about the rspec-users mailing list