运行整个规范时Rspec失败

时间:2011-07-13 14:28:06

标签: ruby-on-rails rspec

当我写rspec并逐行运行行号时。 它工作正常并通过。

当我运行整个rspec时,它失败

      context "scope" do
          before do
            @current_user = User.current = User.first
          end

          it "should have user" do
            @current_user.should_not be_nil
          end
      end

我花了几个小时才发现它失败的原因。

1 个答案:

答案 0 :(得分:2)

我很确定你的测试是干扰。

使用databasecleaner在每次测试之间自动重置所有内容。

请参见参考资料:

https://github.com/bmabey/database_cleaner

相关问题