所以我试图向我的一个模型添加一个子类,然后创建一个夹具并对其进行测试,但我似乎在此过程中遇到了错误。我真的不知道如何描述这个问题,但我通过以下步骤重新创建了它。如果你想让我在这个问题上添加一些东西,请询问。
安慰
$ hobo new lab --setup
$ cd lab
$ hobo g model foo num:integer
IDE
#inserted into app/models/foo.rb
def do_foo
num*5
end
#create app/models/bar.rb
class Bar < Foo
def doo_foo
num*10
end
end
安慰
$ hobo g migration
IDE
#create test/fixtures/bars.yml
bar_one:
num: 1
#create test/unit/bar_test.rb
require 'test_helper'
class BarTest < ActiveSupport::TestCase
def test_bar
puts Bar.first.do_foo
assert true
end
end
安慰
$ rake test
错误
1) Error:
test_bar(BarTest):
ActiveRecord::StatementInvalid: Could not find table 'bars'