views:

72

answers:

1

I'm using the rakismet gem to submit user content to Akismet for spam testing.

So far every test I have done has classified the content as spam.

I'm starting to think I'm doing something wrong.

Does anyone know why I might be getting all false positives on my test data?

+1  A: 

... Because they're test data ?

You can't rely on real rakismet data in your test. Because any test can be detected as spam one day or an other.
Or just because using rakismet requires that you have an internet connection, which can sometimes not be the case.

You should mock the rakismet methods and force them to return what you expect them to.
For example you can use mocha. And do something like the following :

Object.stubs(:spam?).returns(false)

So your objects will never be spams.

Damien MATHIEU
I'm manually creating users and simulating different IP addresses being sent to Rakismet. I need to check whether I have everything configured correctly. Your proposal would pretend that rakismet always works or always doesn't work. I don't see how that would be relevant.
Richard
Well that's not your job to check whether rakismet works or not. There's some unit testing inside the library itself (http://github.com/jfrench/rakismet/tree/master/spec/). That's where rakismet background job is being tested.
Damien MATHIEU
You can include rakismet's rspec stories in your application if you wish. But when you test your model, yes, you should be supposing that everything works fine.
Damien MATHIEU
You seem to be assuming that I have set it up correctly. My testing makes me wonder whether I have. The last thing I want is to put this into production and have all of my users get blocked from submitting any content to my app. That would be a disaster and my current testing seems to suggest that that would be the outcome.
Richard