I have an integraton test that is run using selenium. In my before each i build a few objects and index with solr. I can see the activity in my subnsspot solr test log. And then in my test I perform a search and get an error because my sunspot solr server isn't running. That's because it's running with RAILS_ENV = test.
Here's my before each:
before :each do
Sunspot.remove_all!(Residential)
Sunspot.commit
@prop1 = FactoryGirl.create(:residential, { subdivision: "Steiner Ranch", street_name: "propone" })
@prop1.index!
@prop2 = FactoryGirl.create(:residential, { subdivision: "Jester Estates", street_name: "proptwo" })
@prop2.index!
@prop3 = FactoryGirl.create(:residential, { subdivision: "Cypress Ranch", street_name: "propthree" })
@prop3.index!
end
And here is my test:
it "single word", :js => true do
visit '/'
fill_in 'subdivision', :with => 'cypress'
page.should_not have_content('propone')
page.should_not have_content('proptwo')
page.should have_content('propthree')
end
Any idea why the search is running in development environment and not test environment? I have ENV["RAILS_ENV"] ||= 'test' as the first line in my spec_helper.
I had this same issue. It turns out the Rails app I had running actually specified ENV["RAILS_ENV"] = 'development' in a configuration file (an Apache config file since we are using passenger).
If this is the case for you, then you can replace
ENV["RAILS_ENV"] ||= 'test'
with
ENV["RAILS_ENV"] = 'test'
in your spec_helper.
I did that since
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With