2014-09-18 42 views
0

我有rspec配置安装在我的rails应用程序。它工作正常(我们只是试验rspec,因此只有2个测试)。RSpec是冻结

他们工作正常。现在当使用数据库执行测试时,rspec会冻结。

我只是冻结。我甚至不知道要开始寻找,因为输出中没有错误。

是否有RSpec的详细或调试模式或有人遇到过这种情况?

我试过了-b,但它冻结之前可以给一个错误。

输出:(Rspec的配置有--format文档)

[[email protected]:~] rspec 
User 

比,仅此而已。它挂起。我必须手动重置计算机两次。

这是user_spec.rb

require 'spec_helper' 

describe User do 

    let(:user) { User.create({ 
    username: "teste", 
    email: "[email protected]", 
    name: "Teste", 
    phone: "123456789", 
    password: "123456", 
    notes: "Teste" 
    }) } 
    subject { user } 

    it "is invalid without a username" do 
    user.username = nil 
    is_expected.not_to be_valid 
    end 
end 

而且我spec_helper.rb

# This file is copied to spec/ when you run 'rails generate rspec:install' 
ENV["RAILS_ENV"] ||= 'test' 
require File.expand_path("../../config/environment", __FILE__) 
require 'rspec/rails' 

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } 

# Checks for pending migrations before tests are run. 
ActiveRecord::Migration.maintain_test_schema! 

RSpec.configure do |config| 
    config.infer_base_class_for_anonymous_controllers = false 
    config.order = "random" 
    config.color = true 
    config.tty = true 
    config.formatter = :documentation #:progress, :html, :textmate 
    config.expect_with :rspec do |c| 
    c.syntax = :expect 
    end 
end 

SOLUTION

事实证明,delayed_job_active_record宝石是造成挂。

我不知道为什么,但作为@Greg Malcolm,我查看了log/teste.log,rspec在创建延迟作业数据库并设置新用户后正在进行费用测试。

我已经限制了开发和生产环境的宝石,它的工作!

+0

您可以显示一个控制台输出,告诉您在冻结前有多远,以便我们可以更好地了解冻结发生的位置?特别是我有兴趣看看轨道环境是否成功加载。 – 2014-09-18 19:25:32

+1

这就是问题所在。没有输出!我有一个“描述用户名”和其中的一些例子。我已经配置rspec以文档格式输出。所以它打印'User'然后挂起。 – lcguida 2014-09-18 19:27:04

+0

什么版本的导轨?您的测试数据库可能已过时,请尝试运行'rake db:test:prepare' – Anthony 2014-09-18 19:30:19

回答

1

我还没有听说过rspec的详细功能的耙子。但是查看log/test.log并查看显示的内容可能更有用。它显示数据库活动是冻结效果的一部分。

您可能还想要rails console进行测试,并确保您的数据库连接正常工作。