Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using Mongoid with Rails but all of the functional tests that have been generated are failing with an error similar to:

test_should_get_new(PostsControllerTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: comments: DELETE FROM "comments"

These are the tests that are generated:

require 'test_helper'

class PostsControllerTest < ActionController::TestCase
  setup do
    @post = posts(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:posts)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  [...]
end

Am I supposed to change the tests? Or remove some reference to ActiveRecord or Sqlite? (I still have sqlite in my gemfile because I had issues removing it and am still unsure about how to completely remove it from the app since I'm not using it for anything)

share|improve this question

2 Answers 2

In config/application.rb, remove require "rails/all" and add

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"

In config/development.rb comment / remove the following:

config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5

In config/test.rb comment / remove the following:

config.active_record.mass_assignment_sanitizer = :strict

If it's not working, can you show me your spec_helper.rb please ?

share|improve this answer

If you type

rails --help

then the option to skip Active Record is listed

-O, [--skip-active-record]     # Skip Active Record files

I suggest that you create a new Rails project using this option to remove all vestiges of Active Record, including all of the pieces that Pierre-Louis mentioned, plus others like test fixtures, then recreate/reimport your model and test code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.