当运行我的所有规范时,rspec冻结并在日志文件中存在以下内容:
UncaughtThrowError - uncaught throw :warden:
devise (3.5.1) lib/devise/hooks/activatable.rb:8:in `block in <top (required)>'
warden (1.2.3) lib/warden/hooks.rb:14:in `block in _run_callbacks'
warden (1.2.3) lib/warden/hooks.rb:9:in `_run_callbacks'
warden (1.2.3) lib/warden/manager.rb:53:in `_run_callbacks'
warden (1.2.3) lib/warden/proxy.rb:179:in `set_user'
warden (1.2.3) lib/warden/test/helpers.rb:20:in `block in login_as'
warden (1.2.3) lib/warden.rb:38:in `block in test_mode!'
warden (1.2.3) lib/warden/hooks.rb:14:in `block in _run_callbacks'
warden (1.2.3) lib/warden/hooks.rb:9:in `_run_callbacks'
warden (1.2.3) lib/warden/manager.rb:53:in `_run_callbacks'
warden (1.2.3) lib/warden/proxy.rb:31:in `initialize'
warden (1.2.3) lib/warden/manager.rb:33:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.3) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks'
actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
airbrake (4.3.0) lib/airbrake/rails/middleware.rb:13:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
airbrake (4.3.0) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (4.3.0) lib/airbrake/user_informer.rb:12:in `call'
railties (4.2.3) lib/rails/engine.rb:518:in `call'
railties (4.2.3) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/urlmap.rb:66:in `block in call'
rack (1.6.4) lib/rack/urlmap.rb:50:in `call'
capybara (2.4.4) lib/capybara/server.rb:19:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/Users/karmet/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/karmet/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/karmet/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Started POST "/__better_errors/6cbad9a74efd7260/variables" for 127.0.0.1 at 2015-07-09 12:25:33 +0200
(1.8ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "shifts" DISABLE TRIGGER ALL;ALTER TABLE "templates" DISABLE TRIGGER ALL;ALTER TABLE "roles" DISABLE TRIGGER ALL;ALTER TABLE "locations" DISABLE TRIGGER ALL;ALTER TABLE "location_assignments" DISABLE TRIGGER ALL;ALTER TABLE "instructions" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_pages" DISABLE TRIGGER ALL;ALTER TABLE "news" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_sites" DISABLE TRIGGER ALL;ALTER TABLE "absences" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_layouts" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_snippets" DISABLE TRIGGER ALL;ALTER TABLE "sms_dispatches" DISABLE TRIGGER ALL;ALTER TABLE "sms" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_blocks" DISABLE TRIGGER ALL;ALTER TABLE "profiles" DISABLE TRIGGER ALL;ALTER TABLE "shift_requests" DISABLE TRIGGER ALL;ALTER TABLE "emails" DISABLE TRIGGER ALL;ALTER TABLE "email_recipients" DISABLE TRIGGER ALL;ALTER TABLE "documents" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_files" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_categorizations" DISABLE TRIGGER ALL;ALTER TABLE "users" DISABLE TRIGGER ALL;ALTER TABLE "template_shifts" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_categories" DISABLE TRIGGER ALL;ALTER TABLE "comfy_cms_revisions" DISABLE TRIGGER ALL;ALTER TABLE "booked_shifts" DISABLE TRIGGER ALL
(144.6ms) TRUNCATE TABLE "public"."shifts", "public"."templates", "public"."location_assignments", "public"."comfy_cms_pages", "public"."news", "public"."comfy_cms_sites", "public"."absences", "public"."sms", "public"."comfy_cms_layouts", "public"."comfy_cms_snippets", "public"."comfy_cms_blocks", "public"."sms_dispatches", "public"."profiles", "public"."shift_requests", "public"."emails", "public"."email_recipients", "public"."documents", "public"."comfy_cms_files", "public"."comfy_cms_categorizations", "public"."users", "public"."template_shifts", "public"."comfy_cms_categories", "public"."comfy_cms_revisions", "public"."booked_shifts" RESTART IDENTITY CASCADE;
(1.0ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "shifts" ENABLE TRIGGER ALL;ALTER TABLE "templates" ENABLE TRIGGER ALL;ALTER TABLE "roles" ENABLE TRIGGER ALL;ALTER TABLE "locations" ENABLE TRIGGER ALL;ALTER TABLE "location_assignments" ENABLE TRIGGER ALL;ALTER TABLE "instructions" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_pages" ENABLE TRIGGER ALL;ALTER TABLE "news" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_sites" ENABLE TRIGGER ALL;ALTER TABLE "absences" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_layouts" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_snippets" ENABLE TRIGGER ALL;ALTER TABLE "sms_dispatches" ENABLE TRIGGER ALL;ALTER TABLE "sms" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_blocks" ENABLE TRIGGER ALL;ALTER TABLE "profiles" ENABLE TRIGGER ALL;ALTER TABLE "shift_requests" ENABLE TRIGGER ALL;ALTER TABLE "emails" ENABLE TRIGGER ALL;ALTER TABLE "email_recipients" ENABLE TRIGGER ALL;ALTER TABLE "documents" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_files" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_categorizations" ENABLE TRIGGER ALL;ALTER TABLE "users" ENABLE TRIGGER ALL;ALTER TABLE "template_shifts" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_categories" ENABLE TRIGGER ALL;ALTER TABLE "comfy_cms_revisions" ENABLE TRIGGER ALL;ALTER TABLE "booked_shifts" ENABLE TRIGGER ALL
(0.5ms) BEGIN
在我的功能规格中,我包含一个名为FeatureHelper
的模块,其中包含以下内容:
module FeatureHelper
def self.included(base)
base.class_eval do
include Warden::Test::Helpers
before :each do
Warden.test_mode!
login_as user
end
after :each do
Warden.test_reset!
end
end
end
end
在功能规范中,我使用let(:user) { create(:user) }
设置用户。
当我单独运行所有规格时,一切正常。当我使用bundle exec rspec
运行所有规范时,我只会遇到此问题。
任何想法可能是什么问题?
答案 0 :(得分:2)
似乎是database_cleaner
目前在master
分支上修复的错误。
将此添加到我的Gemfile:
gem 'database_cleaner', github: 'DatabaseCleaner/database_cleaner', ref: 'b8edac6bd04fb89a267201fa8d47066d511fd9de'
现在一切都恢复正常了。
答案 1 :(得分:1)
其实我的修复是在sign_in之前设置user.confirmed_at = Time.now
。
原因是如果尚未确认confirmable
资源,则设计中的可激活挂钩会引发错误。