Atom.project.getPath() in specs


#1

I am trying to write some specs for https://github.com/Arcath/jekyll-atom (I apologise for releasing a package with no specs) and I’m hitting a brick wall around using atom.project.getPath()

https://github.com/Arcath/jekyll-atom/blob/master/lib/server.coffee#L5

It is used to set the cwd of the child_process when someone starts the server.

When I try to run my specs I get the error "TypeError: Cannot read property 'getPath' of null at /Users/arcath/.atom/packages/jekyll/lib/server.coffee:5:22 which is saying to me that atom.project is null during the specs. How can I set it before running the tests?


#2

Most Atom specs that need the path to be set to something just set it to a temp directory in the beforeEach of the outermost describe block:

https://github.com/atom/whitespace/blob/master/spec/whitespace-spec.coffee#L10

Also, the whitespace package was at one point designed to be the “example for how to write package specs” package. I always refer to it first whenever I have a question for how to write specs.


#3

Thanks I will look at that now!


#4

Also, atom.project.getPath is deprecated, so I recommend using atom.project.getPaths instead.