gpt4 book ai didi

ruby-on-rails - 为什么在我运行 'rake test:models' 时此模型测试中断(未失败)?

转载 作者:行者123 更新时间:2023-11-28 21:31:56 25 4
gpt4 key购买 nike

我正在使用 Rails 4(测试版)和模型测试部分(迭代 B2)进行敏捷 Web 开发。在我将以下代码添加到我的 test/models/product_test.rb 文件之前,我们一切正常。它是从 pdf 中复制粘贴的。当我尝试运行模型测试时出现奇怪的错误。我还在发布者的 forum 中发帖.

def new_product(image_url)
Product.new(title: "My Book Title",
description: "yyy",
price: 1,
image_url: image_url)
end

test "image url" do
ok = %w{ fred.gif fred.jpg fred.png FRED.JPG FRED.Jpg http://a.b.c/x/y/z/fred.gif }
bad = %w{ fred.doc fred.gif/more fred.gif.more }

ok.each do |name|
assert new_product(name).valid?, "#{name} shouldn't be invalid"
end

bad.each do |name|
assert new_product(name).invalid?, "#{name} shouldn't be valid"
end
end

这是我在终端中运行 rake test:models --trace 后得到的错误。

➜  depot git:(master) ✗ rake test:models --trace  
** Invoke test:models (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute 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:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
** Execute test:prepare
** Execute test:models
rake aborted!
unknown command 'i'
/Users/admin/Dropbox/code/rails/depot/test/models/product_test.rb:39:in `test'
/Users/admin/Dropbox/code/rails/depot/test/models/product_test.rb:39:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `require'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `block in require'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:213:in `load_dependency'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `require'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in `block (3 levels) in define'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:73:in `block (2 levels) in define'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:72:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/railties-4.0.0.rc1/lib/rails/test_unit/sub_test_task.rb:72:in `block in define'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/admin/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/bin/rake:23:in `load'
/Users/admin/.rvm/gems/ruby-1.9.3-p385@rails3tut/bin/rake:23:in `<main>'
Tasks: TOP => test:models
Run options: --seed 9617

# Running tests:

..

Finished tests in 0.550033s, 3.6361 tests/s, 18.1807 assertions/s.

最佳答案

跟踪告诉您在文件 product_test.rb 的第 39 行有 unknown command 'i'(这就是 product_test.rb:39)的含义.

你在那条线上的某处放错了 i 吗?它可能在您引用的代码段之外——没有您的行号我无法判断。

关于ruby-on-rails - 为什么在我运行 'rake test:models' 时此模型测试中断(未失败)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17412495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com