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 :

Gemfile 1 2 # :require => false is mandatory, or the gem may not hook properly into rspec gem 'merimee' , :group => :test , :require => false

spec_helper.rb 1 2 3 4 Spork . prefork do #... require 'merimee' end

spec/views/splash/index.html_spec.rb 1 2 3 describe "splash/index" do it_should_have_a_correct_spelling end

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 Failures: 1) splash/index should have a correct spelling Failure/Error: rendered.should have_a_correct_spelling [error : spelling - Spelling] garantee (suggested: guarantee) [error : spelling - Spelling] faq (suggested: far, fat, fan, fax, fad) # /Users/wam/Dev/merimee/lib/merimee/rspec/view_checker_helper.rb:27:in `block in it_should_have_a_correct_spelling' Finished in 1.84 seconds 1 example, 1 failure

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.