思维狮身人面像和功能测试存在问题

| 这是我的测试(与should助手一起使用):
  context \"searching from header\" do
    setup do
      Factory(:city, :name => \'Testing It\')
      ThinkingSphinx::Test.index \'city_core\', \'city_delta\'
      ThinkingSphinx::Test.start

      get :index,
          :query => \'Testing It\'
    end

    should respond_with(:success)
    should assign_to(:results)
    should \"have one city on the result\" do
      assert_equal( assigns(:results).count, 1 )
      assert_kind_of( assigns(:results).first, City )
    end

    ThinkingSphinx::Test.stop
  end
一切正常,除了测试总是说结果计数为0而不是1。 我已经调试了这段代码,并且当请求到达控制器时,Sphinx索引完全为空,即使对其有明确的索引调用也是如此。 我在这里做错什么了吗? 任何帮助表示赞赏。     
已邀请:
我发现了问题...甚至在数据库中的插入恰好在具有事务性固定装置的“ 1”之前,在“ 2”块之后也删除了记录。 解决方案将以下行添加到测试中:
self.use_transactional_fixtures = false
希望这对遇到同样问题的人有所帮助。     

要回复问题请先登录注册