Module: SunspotTest
- Defined in:
- lib/sunspot_test.rb
Defined Under Namespace
Classes: TimeOutError
Class Attribute Summary collapse
Class Method Summary collapse
- .setup_solr ⇒ Object
- .start_sunspot_server ⇒ Object
-
.stub ⇒ Object
Stubs Sunspot calls to Solr server.
-
.unstub ⇒ Object
Resets Sunspot to call Solr server, opposite of stub.
Class Attribute Details
.server ⇒ Object
20 21 22 |
# File 'lib/sunspot_test.rb', line 20 def server @server ||= Sunspot::Rails::Server.new end |
.solr_startup_timeout ⇒ Object
11 12 13 |
# File 'lib/sunspot_test.rb', line 11 def solr_startup_timeout @solr_startup_timeout || 15 end |
Class Method Details
.setup_solr ⇒ Object
15 16 17 18 |
# File 'lib/sunspot_test.rb', line 15 def setup_solr unstub start_sunspot_server end |
.start_sunspot_server ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sunspot_test.rb', line 24 def start_sunspot_server unless solr_running? pid = fork do STDERR.reopen("/dev/null") STDOUT.reopen("/dev/null") server.run end at_exit { Process.kill("TERM", pid) } wait_until_solr_starts end end |
.stub ⇒ Object
Stubs Sunspot calls to Solr server
39 40 41 42 43 44 |
# File 'lib/sunspot_test.rb', line 39 def stub unless @session_stubbed Sunspot.session = Sunspot::Rails::StubSessionProxy.new(original_sunspot_session) @session_stubbed = true end end |
.unstub ⇒ Object
Resets Sunspot to call Solr server, opposite of stub
47 48 49 50 51 52 |
# File 'lib/sunspot_test.rb', line 47 def unstub if @session_stubbed Sunspot.session = original_sunspot_session @session_stubbed = false end end |