I am relatively new to Rails. I have a model Micropost, and it has an attribute "content" that I validate presence for. This model is also searchable using sunspot
class Micropost < ActiveRecord::Base
searchable do
text :content, boost: 5
text :tag_list, boost: 2
text :details
end
validates :content, presence: true
end
I am trying to run a simple rspec test in my micropost_sepc.rb
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
But I am getting this error
1) Micropost validations requires content
Failure/Error: Micropost.create(valid_attributes)
Errno::ECONNREFUSED:
Connection refused
Which I am assuming is in someway related to sunspot. I really have no clue how to approach this problem - obviously there must be a way around this.
I'd be really grateful for some guidance (point in the right direction at least)
Try running the solr server in test mode like this:
bundle exec rake sunspot:solr:start RAILS_ENV=test