0

我开始认为它是我正在使用 ruby​​-1.9.3-p125 的 ruby​​ 版本,或者当你的新宝石很难分辨时。我正在根据《Agile Web Development with Rails 4th edition》一书构建一个购物车应用程序。如果有谁能提供帮助,我将不胜感激,谢谢

new-host:depot Tony$ rake test:units
/Users/Tony/work/depot/test/unit/product_test.rb:1:in `test': wrong number of arguments (1 for 2) (ArgumentError)
    from /Users/Tony/work/depot/test/unit/product_test.rb:1:in `<top (required)>'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /Users/Tony/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/Users/Tony/.rvm/rubies/ruby-1.9.3-p125...]
4

1 回答 1

1

我一直在处理同样的错误几个小时,希望这会有所帮助

你的 test/unit/product_test.rb 应该是这样的

class PostTest < ActiveSupport::TestCase
    test "product attributes must not be empty" do
      product = Product.new
      assert product.invalid?
      assert product.errors[:title].any?
      assert product.errors[:description].any?
      assert product.errors[:price].any?
      assert product.errors[:image_url].any?
    end
end
于 2012-08-31T19:38:11.120 回答