RSpec 和太阳黑子:Errno::ECONNREFUSED。这是如何解决的?

RSpec and Sunspot: Errno::ECONNREFUSED. How is this solved?

我对 Rails 比较陌生。我有一个模型 Micropost,它有一个属性 "content",我验证了它的存在。也可以使用 sunspot

搜索此模型
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 

我假设这在某种程度上与太阳黑子有关。我真的不知道如何解决这个问题——显然必须有办法解决这个问题。

非常感谢您提供一些指导(至少指出正确的方向)

像这样在测试模式下尝试 运行 solr 服务器:

bundle exec rake sunspot:solr:start RAILS_ENV=test