Sunspot and RSpec fail. The end doesn't seem to work

I have some tests with RSpec for the Rails site, but despite following the instructions, things don't quite behave.

I create an article through Factory, run Sunspot.commit, and then check the results. I always seem to have drawn a space, though. When I test it manually through the console or through the website, everything works though.

Any ideas? How can I display sunspot logs to find out what is happening?

My Gemfile has the following: I am running Rails 3.1.1

gem 'sunspot', '1.2.1' gem 'sunspot_rails' gem 'sunspot_test' 

Thanks a lot Graeme

+4
source share
2 answers

It was my mistake that you did not read the manual correctly.

https://github.com/collectiveidea/sunspot_test/issues/9

You need to add a magic bit to the description to make sure Solr is running.

 describe "my nice test", :search => true do thing = Factory.create(:thing) Sunspot.commit # do my search and test # now it works! end 

This is important : search => true .

+9
source

Just add a little something to the answer above; if FactoryGirl is used:

 FactoryGirl.define do after(:create) { Sunspot.commit } ... end 

you will not need to add a commit call to each test file ...

0
source

Source: https://habr.com/ru/post/894589/


All Articles