I've attached here a second patch that adds support for always inserting a utf-8 encoding comment. I've also simplified a bit the code of `ruby-mode-set-encoding' (by breaking it into several functions) as it was quite convoluted. 


On 7 November 2013 13:06, Dmitry Gutov <dgutov@yandex.ru> wrote:
On 07.11.2013 12:23, Bozhidar Batsov wrote:
Btw, Dimitry - please add some info the ruby-mode.el about running the
tests. I tried evaluating and running them manually, but this crashed my
Emacs (the tests hogged my CPU completely and I had to kill Emacs).
Maybe there is something wrong with them right now, or perhaps they
should invoked in some manner I'm not aware of.

I'm not aware of any problems running the tests, looks like a bug. Weren't you able to stop the freezing with C-g, at least?

I just open ruby-mode-tests.el, M-x eval-buffer, M-x ert RET.
They run fine.