- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚刚将我的项目更新到 Rails 4。我浏览了 Rails 4 Upgrade Guide .除测试外一切正常。我正在使用 Ruby 2.0.0-p451 和 Rails 4.0.4这些是我的 gem :
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.9.0)
Using atomic (1.1.16)
Using thread_safe (0.3.0)
Using tzinfo (0.3.39)
Using activesupport (4.0.4)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.4)
Using mime-types (1.25.1)
Using polyglot (0.3.4)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.4)
Using activemodel (4.0.4)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.4)
Using bcrypt (3.1.7)
Using thor (0.18.1)
Using railties (4.0.4)
Using bootstrap-datepicker-rails (1.3.0.1)
Using bundler (1.5.3)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using coffee-rails (4.0.1)
Using daemons (1.1.9)
Using docile (1.1.3)
Using dynamic_form (1.1.4)
Using eventmachine (1.0.3)
Using fancybox-rails (0.2.1)
Using hike (1.2.3)
Using jquery-rails (3.1.0)
Using jquery-ui-rails (4.2.0)
Using json (1.8.1)
Using mysql2 (0.3.15)
Using tilt (1.4.1)
Using sprockets (2.11.0)
Using sprockets-rails (2.0.1)
Using rails (4.0.4)
Using rails-i18n (4.0.1)
Using rails-perftest (0.0.3)
Using ruby-prof (0.14.2)
Using sass (3.2.16)
Using sass-rails (4.0.2)
Using select2-rails (3.5.4)
Using simplecov-html (0.8.0)
Using simplecov (0.8.2)
Using thin (1.6.2)
Using turbolinks (2.2.1)
Using uglifier (2.5.0)
这是我的 test_helper.rb:
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
这是我收到的错误代码:
C:\ruby-2.0.0-p451\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;
load($0=ARGV.shift) C:\IssueManager\bin\rake test --trace
Testing started at 15:50 ...
** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:test:purge
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load
** Invoke db:test:load
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
** Execute test:prepare
** Execute test:units
rake aborted!
undefined method `maintain_test_schema!' for #<ActiveRecord::Migration:0x2a4df70>
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activerecord-4.0.4/lib/active_record/migration.rb:628:in `block in method_missing'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activerecord-4.0.4/lib/active_record/migration.rb:601:in `block in say_with_time'
C:/ruby-2.0.0-p451/lib/ruby/2.0.0/benchmark.rb:281:in `measure'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activerecord-4.0.4/lib/active_record/migration.rb:601:in `say_with_time'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activerecord-4.0.4/lib/active_record/migration.rb:621:in `method_missing'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activerecord-4.0.4/lib/active_record/migration.rb:387:in `method_missing'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_help.rb:18:in `<top (required)>'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/IssueManager/test/test_helper.rb:4:in `<top (required)>'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/IssueManager/test/helpers/application_helper_test.rb:1:in `<top (required)>'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/sub_test_task.rb:73:in `block (3 levels) in define'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/sub_test_task.rb:73:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/sub_test_task.rb:73:in `block (2 levels) in define'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/sub_test_task.rb:72:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/sub_test_task.rb:72:in `block in define'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:197:in `block in invoke_prerequisites'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:195:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/railties-4.0.4/lib/rails/test_unit/testing.rake:61:in `block in <top (required)>'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
C:/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
C:/IssueManager/bin/rake:4:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Tasks: TOP => test:run => test:units
Run options: --seed 19194
# Running tests:
Finished tests in 0.034003s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
Process finished with exit code 0
我不知道为什么会这样。如果您需要有关我的项目/系统的更多信息,请随时询问。
编辑:
没有调用 'maintain_test_schema!' 的迁移文件,在 test_help.rb 中调用:
# Make double-sure the RAILS_ENV is not set to production,
# so fixtures aren't loaded into that environment
abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
require 'active_support/testing/autorun'
require 'active_support/test_case'
require 'action_controller/test_case'
require 'action_dispatch/testing/integration'
require 'rails/generators/test_case'
# Config Rails backtrace in tests.
require 'rails/backtrace_cleaner'
if ENV["BACKTRACE"].nil?
Minitest.backtrace_filter = Rails.backtrace_cleaner
end
if defined?(ActiveRecord::Base)
ActiveRecord::Migration.maintain_test_schema!
class ActiveSupport::TestCase
include ActiveRecord::TestFixtures
self.fixture_path = "#{Rails.root}/test/fixtures/"
end
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
def create_fixtures(*fixture_set_names, &block)
FixtureSet.create_fixtures(ActiveSupport::TestCase.fixture_path, fixture_set_names, {}, &block)
end
end
我刚刚用一个模型创建了一个新项目,但即使在那里我也收到了这个错误:
C:\ruby-2.0.0-p451\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\rails4test\bin\rake test
Testing started at 16:46 ...
Run options: --seed 46775
# Running tests:rake aborted!
undefined method `maintain_test_schema!' for #<ActiveRecord::Migration:0x291a290>
C:/rails4test/test/test_helper.rb:3:in `<top (required)>'
C:/rails4test/test/models/test_test.rb:1:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Tasks: TOP => test:run => test:units
(See full trace by running task with --trace)
Finished tests in 0.003000s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
Process finished with exit code 1
最佳答案
ActiveRecord::Migration.maintain_test_schema!
是 Rails 4.1.x 的一部分
这在 4.0.x 中不可用
关于ruby-on-rails - Rails 4 测试根本没有运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22510440/
sanitize 是什么意思在 Rails 中是什么意思? 我正在阅读 CanCanCan 的文档.它说: When using strong_parameters or Rails 4+, you
在过去的几个月里,我感觉自己对 Ruby on Rails (RoR) 开发的了解达到了极限。我为大/小客户和 friend /爱好项目开发了大大小小的应用程序。我知道如何开发这些应用程序,但开始感觉
我昨天参加了一个关于扩展 Rails 的聚会,其中一个主题是 Hexagonal Rails。然而,我只做了一年的 Rails,对 MVC 结构非常满意(也许太舒服了),所以我不太了解适配器和消息队列
我使用多个 Rails 应用程序,一些在 Rails 3.2/Ruby 2.0 上,一些在 Rails 2.3/Ruby 1.8.7 上。 他们的共同点是,随着他们的成长和添加更多的依赖项/ gem
这个问题在这里已经有了答案: Using Rails-UJS in JS modules (Rails 6 with webpacker) (5 个答案) 关闭 3 年前。 我正在尝试使用 UJS
我正在开发一个当前使用 Rails 1.2 的 Rails 应用程序,所以我现在离最新的稳定版本(Rails 2.3)还有很长的路要走。 我应该如何进行迁移到更新版本的 Rails 的过程? 我应该一
尝试按照 Ryan Bates Backbone.js 教程构建抽奖应用程序,但我已经遇到了第一段代码的问题。在 application.js 的 init 函数中,他初始化了 Raffler 路由的
我正在使用 Rails 3.2 并且我有一个数据库表,我想在其中找到符合以下条件的所有行: a = true and b = true and ( 0 true, :b =>
我有一个用户类和一个联系人,其中联系人是用户的子类。这两个类都存储在用户表中。 我的联系人可能有也可能没有电子邮件地址,而我的用户需要一个电子邮件地址(我的用户模型定义中有 validates_pre
我正在编写一个教程,我在其中演示了一些 rails 命令。在我的机器上 rails和 script/rails两者都同样有效。有“首选”形式吗?两者中哪一个更普遍? 最佳答案 当您运行 rails 时
我正在寻找有关通过我的应用程序前进的最佳方式的建议,这是我首次开始集成Elasticsearch。我是一名初学者,但是热衷于深入研究,以便原谅任何明显的错误! 我遵循了http://www.sitep
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我有 Rails 4,这是我的默认版本(我仍然希望它是)。但我不想在我的电脑上添加 rails 3.2。在以下命令中:gem install rails -v 3.2.16 我有这个警告: railt
您好,我想使用 Sheevaplug 构建一个“Rails Brick”来自 Marvell(操作系统是开箱即用的 Ubuntu,但您可以在其上安装其他发行版)。它将成为家庭服务器和静音、低成本(99
我需要能够从 Rails 控制台发送我的 Rails 应用程序的 Postgres 数据库中所有未接受的邀请。 (我有一个名为 Invitations 的表,其中包含一个名为 accepted 的 b
validate :cannot_modify_if_locked, on: :update def cannot_modify_if_locked if self.locked erro
我正在学习教程(学习 Rails 播客),需要更改以下路由语法,以便它与 Rails 3.0 兼容。谁能帮忙? map.view_page ':name', :controller => 'viewe
我是一名优秀的程序员,十分优秀!