“rake spec” migrates the database every time

前端 未结 3 1754
北荒
北荒 2021-01-26 11:10

When I run any of the rspec tasks via rake, the database seems to be dropped and migrated, but if I run them via script/spec path/to/spec, it doesn\'t. Is there an option I can

3条回答
  •  旧时难觅i
    2021-01-26 11:42

    For what I do I want it off permanently. So with rspec 2.5.0 and rails 3:

    Copy rspec.rake to your apps /lib/tasks folder from:

    ~/.rvm/gems/ruby-1.8.7-p302/gems/rspec-rails-2.5.0/lib/rspec/rails/tasks/rspec.rake
    

    Add this to the top of the file:

      Rake::TaskManager.class_eval do
        def remove_task(task_name)
          @tasks.delete(task_name.to_s)
        end
      end
      def remove_task(task_name) 
        Rake.application.remove_task(task_name) 
      end
      remove_task 'spec'
    

    Find and edit this line to force a noop:

    spec_prereq = :noop #Rails.configuration.generators.options[:rails][:orm] == :active_record ?  "db:test:prepare" : :noop
    

提交回复
热议问题