You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gem allows you to "turn on" solr for certain portions
of your tests. For the code that does not use solr, you
would want to "stub" sunspot to avoid unneeded indexing.
$original_sunspot_session stores the original sunspot
session. By default, sunspot_rails uses the SessionProxy::ThreadLocalSessionProxy.
In the first before block, we set the session to a stub session for
every example. Sunspot::Rails::StubSessionProxy is just a dummy class
that skips indexing.
In the second before block, we use RSpec 2's metadata feature by
adding :solr => true. Any example or example group with this metadata
will run the original sunspot session.
Sunspot::Rails::Tester.start_original_sunspot_session starts the solr instance
if it's not running.
Here is an example spec that utilizes sunspot-rails-tester:
require'spec_helper'describe'search page'doit'highlights the active tab in the navigation'do# uses the stub sessionendit'finds and displays a person',:solr=>truedo# uses actual solr - indexing will happenendend
Spork
To get this gem to work with Spork, all you need to do is move the start_original_sunspot_session
line out of the RSpec.configure block: