Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Garbage is left in Redis after a test run #18

vitorbaptista opened this Issue · 3 comments

2 participants



Running the test suite twice gives me this error:

ActiveRecord::RecordNotFound in 'Question catchup algorithm should create a delayed job after requesting a prompt'
Couldn't find Prompt with ID=1937
/home/vitor/Projetos/pairwise-api/vendor/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:1620:in `find_one'
/home/vitor/Projetos/pairwise-api/vendor/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:1603:in `find_from_ids'
/home/vitor/Projetos/pairwise-api/vendor/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:620:in `find'
/home/vitor/Projetos/pairwise-api/app/models/question.rb:528:in `pop_prompt_queue'
/home/vitor/Projetos/pairwise-api/app/models/question.rb:78:in `choose_prompt'

It happens because Redis isn't flushed before the test finished, so when we run again, bad things happen. I can see 3 ways to fix it.

If you think it's possible, I think mocking redis is the best option. It'll probably make the tests run much faster, in exchange of not breaking if we do something bad with the redis integration.

My second option would be to flush redis after each test (vitorbaptista/pairwise-api@24e9ad9). This is very easy to do, but makes the tests slower. In my machine, without this patch, they take ~290s. WIth it, they take 320s.

We could flush only once, when the tests start running, so the performance hit is lessened. But I still prefer running each time, just to be sure that the tests are independent.

What do you think?



Mocking redis sounds like it may be the best option, though flushing redis wouldn't be horrible either. Our tests aren't very fast to begin with so another 30 seconds would be acceptable at this point in my mind.


Mocking redis is easy enough that might be better than flushing.

We just need to add the mock_redis Gem to :test and :cucumber groups and add $redis = somewhere (i.e. spec/spec_helper.rb)

I can send another pull request after you review my first one, or you can go ahead and do it. Whatever you prefer.

Is there any place where I can find you and/or other allourideas' developers? IRC or email... I'm working with pairwise and and I have some questions to make, but I feel github issues isn't the right place to ask :P



Vitor, I merged your other pull request. Thanks!

@lukebaker lukebaker closed this in 7067e23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.