我在我的 Rails 应用程序中使用 PhantomJS 对通过 AJAX 提交的表单进行集成测试。我的测试套件前几次运行绿色,然后最终我遇到了这些错误,这些错误偶尔出现:
1) Admin update admin homepage should allow the admin to change a bicycle's listing to approved
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PG::UnableToSend: : ROLLBACK
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:218:in `rollback_db_transaction'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/transaction.rb:171:in `perform_rollback'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/transaction.rb:110:in `rollback'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:240:in `rollback_transaction'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/fixtures.rb:883:in `block in teardown_fixtures'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/fixtures.rb:882:in `each'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/fixtures.rb:882:in `teardown_fixtures'
# /Users/epicodus/.gem/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/fixtures.rb:718:in `after_teardown'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-rails-2.14.0/lib/rspec/rails/adapters.rb:52:in `block (2 levels) in <module:MiniTestLifecycleAdapter>'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:108:in `call'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:108:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:446:in `run_hook'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:111:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `map'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `run_examples'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:371:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:372:in `map'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:372:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `map'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/reporter.rb:58:in `report'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:25:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
# /Users/epicodus/.gem/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'
2) Admin update admin homepage should text "1 bicycle currently pending"
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::RecordNotFound:
Couldn't find Bicycle with id=515
# ./app/controllers/bicycles_controller.rb:42:in `update'
3) User pages after being redirected to the sign in page, they are redirected back
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `cmd_tuples' for nil:NilClass
# ./app/controllers/bicycles_controller.rb:52:in `block (2 levels) in update'
# ./app/controllers/bicycles_controller.rb:43:in `update'
如果我运行,我可以让套件再次运行绿色
rake db:drop
rake db:create
rake db:schema:load
rake db:test:prepare
但很快问题仍然存在。该功能在开发中正常工作。这是我的宝石文件:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'pg'
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
gem 'paperclip'
gem 'devise'
gem 'bootstrap-sass', :git => 'https://github.com/thomas-mcdonald/bootstrap-sass'
gem 'textacular', "~> 3.0", require: 'textacular/rails'
gem 'will_paginate', '3.0.4'
gem 'will_paginate-bootstrap'
gem 'jquery-ui-rails'
gem "cancan"
gem 'recaptcha-mailhide'
group :production do
gem 'lograge'
gem 'rails_12factor'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'quiet_assets'
end
group :test do
gem 'spork-rails'
gem 'capybara'
gem 'shoulda-matchers'
gem 'launchy'
gem 'poltergeist'
gem 'database_cleaner'
end
group :test, :development do
gem 'rspec-rails'
gem 'pry'
gem 'factory_girl_rails'
end