Reputation: 1977
So I am trying to test for a controller but am running into problems. Part of the code requires a file to be loaded, but I am receiving this error:
Errno::ENOENT:
No such file or directory - ./public/licenses/58efcffc3d8441fcc0627164a8b1350aFCV5Hmashup_lic.xml
However, the file does exit. When I run it in the browser, it works just fine with no problems (but i still want to write a test).
I don't know if this has anything to do with it, but I am using a database when running the test. I know this isn't actually how I should do it, but I don't know any other way.
Any help would be awesome. Thanks.
Upvotes: 0
Views: 1504
Reputation: 2345
Most likely because your assumption about where the current working directory is when running the tests is wrong. try putting a puts File.dirname('.')
in there to make sure you're running from the directory you think you are.
Upvotes: 1
Reputation: 49114
As a debugging tool:
In your test, just before the statement that checks for the file, try adding
puts "list dir " + `ls ./public/licenses/`
to see if the file is really there.
Could be a permissions problem from the test user id
Could also be that the file isn't actually there...
Upvotes: 0