当我尝试运行规范时,出现未初始化的常量错误。我的规范如下所示:
describe Facility do
it { should have_many(:units) }
it { should have_many(:facilities_users) }
it { should have_many(:administrators) }
it { should have_many(:facility_employees) }
end
错误是:
facility_spec.rb:1:in `<top (required)>': uninitialized constant Facility (NameError)
我当然有一个设施模型,所以我不确定为什么会发生这种情况。
最佳答案
您应该尝试运行rakespec
而不是rspecspec
。
但两者都可能有效。
如果不起作用,请尝试bundle exec rspec spec
或bundle exec rake spec
。
关于ruby-on-rails - 为什么我的 Rails 规范无法运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12958985/