# How to write a test for Ultrasphinx

**URL:** <https://www.ruby-forum.com/t/how-to-write-a-test-for-ultrasphinx/130732>\
**Category:** Deployment\
**Created:** [March 2, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/how-to-write-a-test-for-ultrasphinx/130732 "2008-03-02T21:05:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [March 2, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/how-to-write-a-test-for-ultrasphinx/130732/1 "2008-03-02T21:05:59Z")

</div>

Hi All,

I have the ultrasphinx plugin installed and it is working fine, but I’d  
like to write some tests for it.

I have tried putting this test in one of my unit tests:

def test\_should\_run\_ultrasphinx\_query  
@results = Ultrasphinx::Search.new(:query =\> “Second”).run.results  
assert\_equal @results.first.headline, “Second Story”  
end

With a fixture properly defined for the model being searched… but the  
test errors out.

The error I’m getting is:

NoMethodError: You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.headline (so, the results set  
comes back as empty).

Anyway, I’m wondering if there is any weirdness to how I have to set up  
test/unit to make it work.

the daemon IS running… If I try the same search in a console, it  
doesn’t run there either (in the test environment - script/console  
test). But, the results set does come back in development  
environment…

Do I need config/ultrasphinx/test.conf ? I have development.conf in  
there, but I’m not sure how to generate test.conf?

Thanks,  
Dustin

---

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [April 4, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/how-to-write-a-test-for-ultrasphinx/130732/2 "2008-04-04T20:26:55Z")

</div>

Hey All, FYI - here’s what we ended up using to test ultrasphinx

[http://stephencelis.com/archive/2008/4/testing-with-ultrasphinx/](http://stephencelis.com/archive/2008/4/testing-with-ultrasphinx/)
