开发者

How to test akismet in a Rails app?

开发者 https://www.devze.com 2022-12-11 12:29 出处:网络
I\'m using the rakismet gem to submit user cont开发者_JAVA百科ent to Akismet for spam testing. So far every test I have done has classified the content as spam.

I'm using the rakismet gem to submit user cont开发者_JAVA百科ent 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?


... 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消