Poetry of Programming

Its about Ruby on Rails – Kiran Soumya

By

Rspec to work with Logger

In order to set expectations on what we actually logged during the method call,assign under before(:each)

@test_logger = StringIO.new

controller.stub!(:logger).and_return(Logger.new(@test_logger))

and then match the log output using @test_logger.string

By

Issue with Guard

I came across this error this morning, “The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource. (Errno::ENOSPC)”

Tried Guard ignore path to .git or tried reducing the watch files under Guardfile, but alas! Guard by default handles that ignore path of .git and still it throws the same crazy error…

Googled the issues under Guard gem, then realized that you need to increase the watch count for the current user on your box to fix this.
# Check current maximum
$ cat /proc/sys/fs/inotify/max_user_watches
8192
# Increase the maximum
$ echo 100000|sudo tee /proc/sys/fs/inotify/max_user_watches
Password:
100000
$ cat /proc/sys/fs/inotify/max_user_watches
100000

This increases max_user_watches temporarily.On Ubuntu, to increase at boot, edit /etc/sysctl.conf and add fs.inotify.max_user_watches=100000.