【发布时间】:2015-05-07 15:44:42
【问题描述】:
我对 Rails 比较陌生。我有一个模型 Micropost,它有一个我验证存在的属性“内容”。这个模型也可以使用太阳黑子搜索
class Micropost < ActiveRecord::Base
searchable do
text :content, boost: 5
text :tag_list, boost: 2
text :details
end
validates :content, presence: true
end
我正在尝试在我的 micropost_sepc.rb 中运行一个简单的 rspec 测试
let(:valid_attributes) {
{content: "Lorem Ipsum is simply dummy text of the printing and typesetting industry."}
}
context "validations" do
let(:micropost) { Micropost.new(valid_attributes) }
before do
Micropost.create(valid_attributes)
end
it "requires content" do
expect(micropost).to validate_presence_of(:content)
end
end
但是我收到了这个错误
1) Micropost validations requires content
Failure/Error: Micropost.create(valid_attributes)
Errno::ECONNREFUSED:
Connection refused
我假设在某种程度上与太阳黑子有关。我真的不知道如何解决这个问题 - 显然必须有办法解决这个问题。
非常感谢您的指导(至少指向正确的方向)
【问题讨论】:
标签: ruby-on-rails solr rspec sunspot