I was working with the RSpec team about some issues with their Windows’ continuous integration build hosted at Appveyor. One of the unit tests was failing on Windows but it was working correctly on Linux. After running only the failing test, I was able to identify the issue with the unit test that was using Ruby’s File.executable? method.
The RSpec team uses Travis CI to run and build their software against Linux operating systems. To run and build their software against Windows, they use Appveyor.
It was strange to me that File.executable? method was working fine on linux but it was failing on Windows. The first thing I did was to read the official Ruby documentation on the File class. After reading the documentation a few times, one word received my attention, “executable”. This is what the documentation says about File.executable?: “Returns
true if the named file is executable by the effective user id of this process.”
In the same document, it says “On non-Posix operating systems, there may be only the ability to make a file read-only or read-write.” This means that the executable permission is not available in Windows. It is only available on *nix operating systems.
After reading the official File documentation, I wanted to see if other projects have experienced the same issue. I was able to find a bug report for Puppet Labs titled “Windows File.executable? now returns false on ruby 1.9.” The team decided to close this bug and made minor changes to their unit tests to be OS specific.
We decided to do the same with the RSpec team. Here is the diff view to see the changes.