When you assign a top-level member variable in CoffeeScript, it is assigned as a property of the global object ( window in the browser). Thus, it generates the following JavaScript:
window.sharedExamplesForThing = ...;
This means that you can reference it outside the file as window.sharedExamplesForThing or just sharedExamplesForThing . So, what you are doing should work, assuming the general example file has been loaded before the specification file. I think the problem that you are facing is that the specification file is loaded first (since the function descriptions are started when the file is downloaded, while the functions are started after all the files are downloaded). Therefore, you may need to adjust the boot order, you can try to place common example files in the support directory, and then request it first.
Instead of assigning variables directly to the window object, it might be better to set up a namespace to export your shared variables (so that you don't clutter up the global object):
window.MyNamespace = {} MyNamespace.sharedExamplesForThing = ...
Then in your spec file you can refer to it as MyNamespace.sharedExamplesForThing .
It is useful for me to look at the generated JavaScript to try to understand how CoffeeScript exports variables between files.
Steve source share