Skip to content

Instantly share code, notes, and snippets.

@dydx
Created January 8, 2016 20:09
Show Gist options
  • Save dydx/309662761d47c9c6a5b2 to your computer and use it in GitHub Desktop.
Save dydx/309662761d47c9c6a5b2 to your computer and use it in GitHub Desktop.
This is the failing test result after creating the spec for CachedScore AR model
RockScore
returns 0 for unpopular terms
returns 10 for popular terms
returns mediocre results for mediocre terms
does not divide by zero
ScoreCache
returns cached scores if they exist (FAILED - 1)
when the term is not cached
recomputes scores (FAILED - 2)
stores new scores in the database (FAILED - 3)
SearchEngine
counts results
Failures:
1) ScoreCache returns cached scores if they exist
Failure/Error: allow(CachedScore).to receive(:for_term).with("microsoft").and_return ( 5.5 )
ActiveRecord::StatementInvalid:
Could not find table 'cached_scores'
# ./spec/services/score_cache_spec.rb:19:in `block (2 levels) in <top (required)>'
2) ScoreCache when the term is not cached recomputes scores
Failure/Error:
allow(CachedScore).to receive(:for_term).with("microsoft").
and_raise( CachedScore::NoScore )
ActiveRecord::StatementInvalid:
Could not find table 'cached_scores'
# ./spec/services/score_cache_spec.rb:26:in `block (3 levels) in <top (required)>'
3) ScoreCache when the term is not cached stores new scores in the database
Failure/Error:
allow(CachedScore).to receive(:for_term).with("microsoft").
and_raise( CachedScore::NoScore )
ActiveRecord::StatementInvalid:
Could not find table 'cached_scores'
# ./spec/services/score_cache_spec.rb:26:in `block (3 levels) in <top (required)>'
Finished in 0.04174 seconds (files took 2.23 seconds to load)
8 examples, 3 failures
Failed examples:
rspec ./spec/services/score_cache_spec.rb:18 # ScoreCache returns cached scores if they exist
rspec ./spec/services/score_cache_spec.rb:31 # ScoreCache when the term is not cached recomputes scores
rspec ./spec/services/score_cache_spec.rb:35 # ScoreCache when the term is not cached stores new scores in the database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment