So it all started when I asked a friend to test this new app I’m building : “On your main page, garantee. You should really check your spelling, people will know you are French !”.
So here I went, naively googling for “website spell checker”, with either pricey reports or simple websites where I’d have to copy-paste my text from all my pages. Then, I found AfterTheDeadline. It looks great, open-source, recently bought by wordpress.com, and they even provide an API.
So, spent my evening doing stuff, and here we are with a new gem : Merimee (github).
What does it do ?
It gives you some rspec macros to test your views spelling, and fails your tests if it finds errors.
Install
So here we are with our existing rails project. Installation is very easy :
1 2 |
|
1 2 3 4 |
|
1 2 3 |
|
And voilĂ , your test should still be green, or fail if there’s a spelling error :
1 2 3 4 5 6 7 8 9 10 |
|
Have a look at the readme to see how you can configure the gem : you can choose which errors make your test fail, and configure your own dictionary to ignore some spelling errors.
Warning
Since AtD server will reject your requests if they are too close from each other, the macro has a nasty sleep 0.7
to make
sure it doesn’t happen. If you find a better solution, send me a pull request. You may want to have these tests only run
in some test groups.
Planned features ?
Oh, I have a few ideas : add a rake task with a full report, for all views, including both errors (spelling etc.) and warnings (grammar warnings generated by AtD, like repetitions, double negations etc. I want to enable merimee in Test::Case as well, but I’m not so used to it.
Feel free to fork and send me your pull requests, or just point any issue you have.