【问题标题】:RSpec and Sunspot: Errno::ECONNREFUSED. How is this solved?RSpec 和太阳黑子:Errno::ECONNREFUSED。这是如何解决的?
【发布时间】: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


    【解决方案1】:

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

    bundle exec rake sunspot:solr:start RAILS_ENV=test
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-08-22
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多