diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 2139cccfb..210a8d329 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -71,7 +71,7 @@ describe "the `atom` global", -> describe "when the package has a main module", -> describe "when the metadata specifies a main module path˜", -> it "requires the module at the specified path", -> - mainModule = require('fixtures/packages/package-with-main/main-module') + mainModule = require('./fixtures/packages/package-with-main/main-module') spyOn(mainModule, 'activate') pack = atom.activatePackage('package-with-main') expect(mainModule.activate).toHaveBeenCalled() @@ -79,7 +79,7 @@ describe "the `atom` global", -> describe "when the metadata does not specify a main module", -> it "requires index.coffee", -> - indexModule = require('fixtures/packages/package-with-index/index') + indexModule = require('./fixtures/packages/package-with-index/index') spyOn(indexModule, 'activate') pack = atom.activatePackage('package-with-index') expect(indexModule.activate).toHaveBeenCalled() @@ -95,7 +95,7 @@ describe "the `atom` global", -> [mainModule, pack] = [] beforeEach -> - mainModule = require 'fixtures/packages/package-with-activation-events/index' + mainModule = require './fixtures/packages/package-with-activation-events/index' spyOn(mainModule, 'activate').andCallThrough() AtomPackage = require 'atom-package' spyOn(AtomPackage.prototype, 'requireMainModule').andCallThrough() @@ -177,9 +177,9 @@ describe "the `atom` global", -> describe "stylesheet loading", -> describe "when the metadata contains a 'stylesheets' manifest", -> it "loads stylesheets from the stylesheets directory as specified by the manifest", -> - one = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css") - two = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less") - three = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css") + one = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css") + two = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less") + three = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css") expect(stylesheetElementForId(one)).not.toExist() expect(stylesheetElementForId(two)).not.toExist() expect(stylesheetElementForId(three)).not.toExist() @@ -193,9 +193,9 @@ describe "the `atom` global", -> describe "when the metadata does not contain a 'stylesheets' manifest", -> it "loads all stylesheets from the stylesheets directory", -> - one = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets/stylesheets/1.css") - two = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets/stylesheets/2.less") - three = fsUtils.resolveOnLoadPath("fixtures/packages/package-with-stylesheets/stylesheets/3.css") + one = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/1.css") + two = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/2.less") + three = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/3.css") expect(stylesheetElementForId(one)).not.toExist() expect(stylesheetElementForId(two)).not.toExist() expect(stylesheetElementForId(three)).not.toExist() diff --git a/spec/directory-spec.coffee b/spec/directory-spec.coffee index 94a29d3b5..a85687dfe 100644 --- a/spec/directory-spec.coffee +++ b/spec/directory-spec.coffee @@ -6,7 +6,7 @@ describe "Directory", -> directory = null beforeEach -> - directory = new Directory(fsUtils.resolveOnLoadPath('fixtures')) + directory = new Directory(path.join(__dirname, 'fixtures')) afterEach -> directory.off() @@ -15,7 +15,7 @@ describe "Directory", -> temporaryFilePath = null beforeEach -> - temporaryFilePath = path.join(fsUtils.resolveOnLoadPath('fixtures'), 'temporary') + temporaryFilePath = path.join(__dirname, 'fixtures', 'temporary') fsUtils.remove(temporaryFilePath) if fsUtils.exists(temporaryFilePath) afterEach -> @@ -84,9 +84,9 @@ describe "Directory", -> expect(directory.relativize(path.join(absolutePath, "file.coffee"))).toBe "file.coffee" it "returns a relative path based on the directory's symlinked source path", -> - symlinkPath = path.join(fsUtils.resolveOnLoadPath('fixtures'), 'symlink-to-dir') + symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') symlinkDirectory = new Directory(symlinkPath) - realFilePath = fsUtils.resolveOnLoadPath('fixtures/dir/a') + realFilePath = require.resolve('./fixtures/dir/a') expect(symlinkDirectory.relativize(symlinkPath)).toBe '' expect(symlinkDirectory.relativize(realFilePath)).toBe 'a' @@ -97,13 +97,13 @@ describe "Directory", -> it "returns true if the path is a child of the directory's path", -> absolutePath = directory.getPath() expect(directory.contains(path.join(absolutePath, "b"))).toBe true - expect(directory.contains(path.join(absolutePath, "b/file.coffee"))).toBe true + expect(directory.contains(path.join(absolutePath, "b", "file.coffee"))).toBe true expect(directory.contains(path.join(absolutePath, "file.coffee"))).toBe true it "returns true if the path is a child of the directory's symlinked source path", -> - symlinkPath = path.join(fsUtils.resolveOnLoadPath('fixtures'), 'symlink-to-dir') + symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') symlinkDirectory = new Directory(symlinkPath) - realFilePath = fsUtils.resolveOnLoadPath('fixtures/dir/a') + realFilePath = require.resolve('./fixtures/dir/a') expect(symlinkDirectory.contains(realFilePath)).toBe true it "returns false if the directory's path is not a prefix of the path", -> diff --git a/spec/environment.coffee b/spec/environment.coffee index 1e78d4074..9fddf9a02 100644 --- a/spec/environment.coffee +++ b/spec/environment.coffee @@ -1,3 +1,4 @@ +path = require 'path' {Site} = require 'telepath' fsUtils = require 'fs-utils' Project = require 'project' @@ -10,7 +11,7 @@ class Environment @run => @project = deserialize(@state.get('project')) else @state = @site.createDocument({}) - @project = new Project(projectPath ? fsUtils.resolveOnLoadPath('fixtures')) + @project = new Project(projectPath ? path.join(__dirname, 'fixtures')) @state.set(project: @project.getState()) clone: (params) -> diff --git a/spec/file-spec.coffee b/spec/file-spec.coffee index 4dd30c982..f2d89800a 100644 --- a/spec/file-spec.coffee +++ b/spec/file-spec.coffee @@ -6,7 +6,7 @@ describe 'File', -> [filePath, file] = [] beforeEach -> - filePath = path.join(fsUtils.resolveOnLoadPath('fixtures'), "atom-file-test.txt") # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test + filePath = path.join(__dirname, 'fixtures', 'atom-file-test.txt') # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test fsUtils.remove(filePath) if fsUtils.exists(filePath) fsUtils.writeSync(filePath, "this is old!") file = new File(filePath) diff --git a/spec/fs-utils-spec.coffee b/spec/fs-utils-spec.coffee index 3fd48d17d..82a399206 100644 --- a/spec/fs-utils-spec.coffee +++ b/spec/fs-utils-spec.coffee @@ -4,16 +4,16 @@ path = require 'path' temp = require 'temp' describe "fsUtils", -> + fixturesDir = path.join(__dirname, 'fixtures') + describe ".read(path)", -> it "return contents of file", -> - expect(fsUtils.read(require.resolve("fixtures/sample.txt"))).toBe "Some text.\n" + expect(fsUtils.read(require.resolve("./fixtures/sample.txt"))).toBe "Some text.\n" it "does not through an exception when the path is a binary file", -> - expect(-> fsUtils.read(require.resolve("fixtures/binary-file.png"))).not.toThrow() + expect(-> fsUtils.read(require.resolve("./fixtures/binary-file.png"))).not.toThrow() describe ".isFileSync(path)", -> - fixturesDir = fsUtils.resolveOnLoadPath('fixtures') - it "returns true with a file path", -> expect(fsUtils.isFileSync(path.join(fixturesDir, 'sample.js'))).toBe true @@ -26,10 +26,10 @@ describe "fsUtils", -> describe ".exists(path)", -> it "returns true when path exsits", -> - expect(fsUtils.exists(fsUtils.resolveOnLoadPath('fixtures'))).toBe true + expect(fsUtils.exists(fixturesDir)).toBe true it "returns false when path doesn't exsit", -> - expect(fsUtils.exists(fsUtils.resolveOnLoadPath("fixtures") + "/-nope-does-not-exist")).toBe false + expect(fsUtils.exists(path.join(fixturesDir, "-nope-does-not-exist"))).toBe false expect(fsUtils.exists("")).toBe false expect(fsUtils.exists(null)).toBe false @@ -42,11 +42,6 @@ describe "fsUtils", -> expect(fsUtils.exists("/tmp/a/b/c")).toBeTruthy() describe ".traverseTreeSync(path, onFile, onDirectory)", -> - fixturesDir = null - - beforeEach -> - fixturesDir = fsUtils.resolveOnLoadPath('fixtures') - it "calls fn for every path in the tree at the given path", -> paths = [] onPath = (childPath) -> @@ -93,7 +88,7 @@ describe "fsUtils", -> describe ".md5ForPath(path)", -> it "returns the MD5 hash of the file at the given path", -> - expect(fsUtils.md5ForPath(require.resolve('fixtures/sample.js'))).toBe 'dd38087d0d7e3e4802a6d3f9b9745f2b' + expect(fsUtils.md5ForPath(require.resolve('./fixtures/sample.js'))).toBe 'dd38087d0d7e3e4802a6d3f9b9745f2b' describe ".list(path, extensions)", -> it "returns the absolute paths of entries within the given directory", -> diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 77efcc50f..b40bfbb94 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -22,29 +22,29 @@ describe "Git", -> describe ".getPath()", -> it "returns the repository path for a .git directory path", -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/master.git/HEAD')) - expect(repo.getPath()).toBe fsUtils.resolveOnLoadPath('fixtures/git/master.git') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'master.git', 'HEAD')) + expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git') it "returns the repository path for a repository path", -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/master.git')) - expect(repo.getPath()).toBe fsUtils.resolveOnLoadPath('fixtures/git/master.git') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'master.git')) + expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git') describe ".isPathIgnored(path)", -> it "returns true for an ignored path", -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/ignore.git')) + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'ignore.git')) expect(repo.isPathIgnored('a.txt')).toBeTruthy() it "returns false for a non-ignored path", -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/ignore.git')) + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'ignore.git')) expect(repo.isPathIgnored('b.txt')).toBeFalsy() describe ".isPathModified(path)", -> [repo, filePath, newPath, originalPathText] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) - filePath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt') - newPath = path.join(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'), 'new-path.txt') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) + filePath = require.resolve('./fixtures/git/working-dir/file.txt') + newPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'new-path.txt') originalPathText = fsUtils.read(filePath) afterEach -> @@ -70,9 +70,9 @@ describe "Git", -> [filePath, newPath] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) - filePath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt') - newPath = path.join(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'), 'new-path.txt') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) + filePath = require.resolve('./fixtures/git/working-dir/file.txt') + newPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'new-path.txt') fsUtils.writeSync(newPath, "i'm new here") afterEach -> @@ -89,10 +89,10 @@ describe "Git", -> [path1, path2, originalPath1Text, originalPath2Text] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) - path1 = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) + path1 = require.resolve('./fixtures/git/working-dir/file.txt') originalPath1Text = fsUtils.read(path1) - path2 = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/other.txt') + path2 = require.resolve('./fixtures/git/working-dir/other.txt') originalPath2Text = fsUtils.read(path2) afterEach -> @@ -132,7 +132,7 @@ describe "Git", -> describe ".destroy()", -> it "throws an exception when any method is called after it is called", -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/master.git/HEAD')) + repo = new Git(require.resolve('./fixtures/git/master.git/HEAD')) repo.destroy() expect(-> repo.getShortHead()).toThrow() @@ -140,8 +140,8 @@ describe "Git", -> [filePath, originalPathText] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) - filePath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) + filePath = require.resolve('./fixtures/git/working-dir/file.txt') originalPathText = fsUtils.read(filePath) afterEach -> @@ -156,8 +156,8 @@ describe "Git", -> [filePath, originalPathText] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) - filePath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt') + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) + filePath = require.resolve('./fixtures/git/working-dir/file.txt') originalPathText = fsUtils.read(filePath) afterEach -> @@ -179,7 +179,7 @@ describe "Git", -> [newPath, modifiedPath, cleanPath, originalModifiedPathText] = [] beforeEach -> - repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir')) + repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) modifiedPath = project.resolve('git/working-dir/file.txt') originalModifiedPathText = fsUtils.read(modifiedPath) newPath = project.resolve('git/working-dir/untracked.txt') diff --git a/spec/project-replication-spec.coffee b/spec/project-replication-spec.coffee index 193b1ba7d..89746412a 100644 --- a/spec/project-replication-spec.coffee +++ b/spec/project-replication-spec.coffee @@ -1,3 +1,4 @@ +path = require 'path' {Site} = require 'telepath' fsUtils = require 'fs-utils' Project = require 'project' @@ -12,8 +13,10 @@ describe "Project replication", -> getOriginUrl: -> 'git://server/project.git' destroy: -> - config.set('core.projectHome', fsUtils.resolveOnLoadPath('fixtures/replication/home-1')) - project1 = new Project(fsUtils.resolveOnLoadPath('fixtures/replication/home-1/project')) + projectHome1 = path.join(__dirname, 'fixtures', 'replication', 'home-1') + projectHome2 = path.join(__dirname, 'fixtures', 'replication', 'home-2') + config.set('core.projectHome', projectHome1) + project1 = new Project(path.join(projectHome1, 'project')) project1.bufferForPath('file-1.txt') project1.bufferForPath('file-1.txt') expect(project1.getBuffers().length).toBe 1 @@ -23,7 +26,7 @@ describe "Project replication", -> connection = doc1.connect(doc2) # pretend we're bootstrapping a joining window - config.set('core.projectHome', fsUtils.resolveOnLoadPath('fixtures/replication/home-2')) + config.set('core.projectHome', projectHome2) project2 = deserialize(doc2) afterEach -> diff --git a/spec/text-buffer-spec.coffee b/spec/text-buffer-spec.coffee index 21f9ca34e..6ee806952 100644 --- a/spec/text-buffer-spec.coffee +++ b/spec/text-buffer-spec.coffee @@ -7,7 +7,7 @@ describe 'TextBuffer', -> [filePath, fileContents, buffer] = [] beforeEach -> - filePath = require.resolve('fixtures/sample.js') + filePath = require.resolve('./fixtures/sample.js') fileContents = fsUtils.read(filePath) buffer = project.bufferForPath(filePath) @@ -22,12 +22,12 @@ describe 'TextBuffer', -> describe "when given a path", -> describe "when a file exists for the path", -> it "loads the contents of that file", -> - filePath = require.resolve 'fixtures/sample.txt' + filePath = require.resolve './fixtures/sample.txt' buffer = project.bufferForPath(filePath) expect(buffer.getText()).toBe fsUtils.read(filePath) it "does not allow the initial state of the buffer to be undone", -> - filePath = require.resolve 'fixtures/sample.txt' + filePath = require.resolve './fixtures/sample.txt' buffer = project.bufferForPath(filePath) buffer.undo() expect(buffer.getText()).toBe fsUtils.read(filePath) @@ -49,7 +49,7 @@ describe 'TextBuffer', -> [filePath, newPath, bufferToChange, eventHandler] = [] beforeEach -> - filePath = path.join(fsUtils.resolveOnLoadPath("fixtures"), "atom-manipulate-me") + filePath = path.join(__dirname, "fixtures", "atom-manipulate-me") newPath = "#{filePath}-i-moved" fsUtils.writeSync(filePath, "") bufferToChange = project.bufferForPath(filePath) @@ -545,7 +545,7 @@ describe 'TextBuffer', -> [filePath, newPath, bufferToChange, eventHandler] = [] beforeEach -> - filePath = path.join(fsUtils.resolveOnLoadPath("fixtures"), "atom-manipulate-me") + filePath = path.join(__dirname, "fixtures", "atom-manipulate-me") newPath = "#{filePath}-i-moved" fsUtils.writeSync(filePath, "") bufferToChange = project.bufferForPath(filePath)