Eliminate fixturesProject global. Use project global instead.

This commit is contained in:
Nathan Sobo 2013-02-28 10:11:06 -07:00 committed by probablycorey
parent 9f7b804a6c
commit 54fc9efdcb
13 changed files with 36 additions and 40 deletions

View File

@ -6,7 +6,7 @@ describe "DisplayBuffer", ->
[editSession, displayBuffer, buffer, changeHandler, tabLength] = []
beforeEach ->
tabLength = 2
editSession = fixturesProject.buildEditSession('sample.js', { tabLength })
editSession = project.buildEditSession('sample.js', { tabLength })
{ buffer, displayBuffer } = editSession
changeHandler = jasmine.createSpy 'changeHandler'
displayBuffer.on 'changed', changeHandler
@ -228,7 +228,7 @@ describe "DisplayBuffer", ->
editSession2 = null
beforeEach ->
editSession2 = fixturesProject.buildEditSession('two-hundred.txt')
editSession2 = project.buildEditSession('two-hundred.txt')
{ buffer, displayBuffer } = editSession2
displayBuffer.on 'changed', changeHandler

View File

@ -9,13 +9,10 @@ describe "EditSession", ->
buffer.setText(buffer.getText().replace(/[ ]{2}/g, "\t"))
beforeEach ->
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
editSession = project.buildEditSession('sample.js', autoIndent: false)
buffer = editSession.buffer
lineLengths = buffer.getLines().map (line) -> line.length
afterEach ->
fixturesProject.destroy()
describe "title", ->
describe ".getTitle()", ->
it "uses the basename of the buffer's path as its title, or 'untitled' if the path is undefined", ->
@ -1736,7 +1733,7 @@ describe "EditSession", ->
it "does not explode if the current language mode has no comment regex", ->
editSession.destroy()
editSession = fixturesProject.buildEditSession(null, autoIndent: false)
editSession = project.buildEditSession(null, autoIndent: false)
editSession.setSelectedBufferRange([[4, 5], [4, 5]])
editSession.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
@ -1814,7 +1811,7 @@ describe "EditSession", ->
expect(editSession.getSelectedBufferRanges()).toEqual [[[1, 6], [1, 6]], [[1, 18], [1, 18]]]
it "restores selected ranges even when the change occurred in another edit session", ->
otherEditSession = fixturesProject.buildEditSession(editSession.getPath())
otherEditSession = project.buildEditSession(editSession.getPath())
otherEditSession.setSelectedBufferRange([[2, 2], [3, 3]])
otherEditSession.delete()
@ -2007,13 +2004,13 @@ describe "EditSession", ->
describe "soft-tabs detection", ->
it "assign soft / hard tabs based on the contents of the buffer, or uses the default if unknown", ->
editSession = fixturesProject.buildEditSession('sample.js', softTabs: false)
editSession = project.buildEditSession('sample.js', softTabs: false)
expect(editSession.softTabs).toBeTruthy()
editSession = fixturesProject.buildEditSession('sample-with-tabs.coffee', softTabs: true)
editSession = project.buildEditSession('sample-with-tabs.coffee', softTabs: true)
expect(editSession.softTabs).toBeFalsy()
editSession = fixturesProject.buildEditSession(null, softTabs: false)
editSession = project.buildEditSession(null, softTabs: false)
expect(editSession.softTabs).toBeFalsy()
describe ".indentLevelForLine(line)", ->

View File

@ -1745,7 +1745,7 @@ describe "Editor", ->
describe "when the switching from an edit session for a long buffer to an edit session for a short buffer", ->
it "updates the line numbers to reflect the shorter buffer", ->
emptyEditSession = fixturesProject.buildEditSession(null)
emptyEditSession = project.buildEditSession(null)
editor.edit(emptyEditSession)
expect(editor.gutter.lineNumbers.find('.line-number').length).toBe 1

View File

@ -10,18 +10,18 @@ describe "LanguageMode", ->
describe "common behavior", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
editSession = project.buildEditSession('sample.js', autoIndent: false)
{ buffer, languageMode } = editSession
describe "language detection", ->
it "uses the file name as the file type if it has no extension", ->
jsEditSession = fixturesProject.buildEditSession('js', autoIndent: false)
jsEditSession = project.buildEditSession('js', autoIndent: false)
expect(jsEditSession.languageMode.grammar.name).toBe "JavaScript"
jsEditSession.destroy()
describe "javascript", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
editSession = project.buildEditSession('sample.js', autoIndent: false)
{ buffer, languageMode } = editSession
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@ -63,7 +63,7 @@ describe "LanguageMode", ->
describe "coffeescript", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('coffee.coffee', autoIndent: false)
editSession = project.buildEditSession('coffee.coffee', autoIndent: false)
{ buffer, languageMode } = editSession
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@ -98,7 +98,7 @@ describe "LanguageMode", ->
describe "css", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('css.css', autoIndent: false)
editSession = project.buildEditSession('css.css', autoIndent: false)
{ buffer, languageMode } = editSession
describe ".toggleLineCommentsForBufferRows(start, end)", ->

View File

@ -262,7 +262,7 @@ describe "TextMateGrammar", ->
describe "when the grammar is CSON", ->
it "loads the grammar and correctly parses a keyword", ->
spyOn(syntax, 'addGrammar')
pack = new TextMatePackage(fixturesProject.resolve("packages/package-with-a-cson-grammar.tmbundle"))
pack = new TextMatePackage(project.resolve("packages/package-with-a-cson-grammar.tmbundle"))
pack.load()
grammar = pack.grammars[0]
expect(grammar).toBeTruthy()

View File

@ -26,7 +26,7 @@ describe "@load(name)", ->
expect($(".editor").css("padding-right")).not.toBe("102px")
expect($(".editor").css("padding-bottom")).not.toBe("103px")
themePath = fixturesProject.resolve('themes/theme-with-package-file')
themePath = project.resolve('themes/theme-with-package-file')
theme = Theme.load(themePath)
expect($(".editor").css("padding-top")).toBe("101px")
expect($(".editor").css("padding-right")).toBe("102px")
@ -36,7 +36,7 @@ describe "@load(name)", ->
it "loads and applies the stylesheet", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
themePath = fixturesProject.resolve('themes/theme-stylesheet.css')
themePath = project.resolve('themes/theme-stylesheet.css')
theme = Theme.load(themePath)
expect($(".editor").css("padding-top")).toBe "1234px"
@ -46,7 +46,7 @@ describe "@load(name)", ->
expect($(".editor").css("padding-right")).not.toBe "20px"
expect($(".editor").css("padding-bottom")).not.toBe "30px"
themePath = fixturesProject.resolve('themes/theme-without-package-file')
themePath = project.resolve('themes/theme-without-package-file')
theme = Theme.load(themePath)
expect($(".editor").css("padding-top")).toBe "10px"
expect($(".editor").css("padding-right")).toBe "20px"

View File

@ -18,7 +18,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains soft-tabs", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
editSession = project.buildEditSession('sample.js', autoIndent: false)
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)
@ -299,7 +299,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains hard-tabs", ->
beforeEach ->
tabLength = 2
editSession = fixturesProject.buildEditSession('sample-with-tabs.coffee', { tabLength })
editSession = project.buildEditSession('sample-with-tabs.coffee', { tabLength })
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)
@ -328,7 +328,7 @@ describe "TokenizedBuffer", ->
describe "when a Git commit message file is tokenized", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('COMMIT_EDITMSG', autoIndent: false)
editSession = project.buildEditSession('COMMIT_EDITMSG', autoIndent: false)
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)
@ -355,7 +355,7 @@ describe "TokenizedBuffer", ->
describe "when a C++ source file is tokenized", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('includes.cc', autoIndent: false)
editSession = project.buildEditSession('includes.cc', autoIndent: false)
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)
@ -386,7 +386,7 @@ describe "TokenizedBuffer", ->
describe "when a Ruby source file is tokenized", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('hello.rb', autoIndent: false)
editSession = project.buildEditSession('hello.rb', autoIndent: false)
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)
@ -403,7 +403,7 @@ describe "TokenizedBuffer", ->
describe "when an Objective-C source file is tokenized", ->
beforeEach ->
editSession = fixturesProject.buildEditSession('function.mm', autoIndent: false)
editSession = project.buildEditSession('function.mm', autoIndent: false)
buffer = editSession.buffer
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
editSession.setVisible(true)

View File

@ -30,8 +30,8 @@ jasmine.getEnv().defaultTimeoutInterval = 5000
beforeEach ->
jQuery.fx.off = true
window.fixturesProject = new Project(require.resolve('fixtures'))
window.project = fixturesProject
window.project = new Project(require.resolve('fixtures'))
window.git = Git.open(fixturesProject.getPath())
window.project.on 'path-changed', ->
window.git?.destroy()

View File

@ -40,7 +40,7 @@ describe "AutocompleteView", ->
beforeEach ->
window.rootView = new RootView
editor = new Editor(editSession: fixturesProject.buildEditSession('sample.js'))
editor = new Editor(editSession: project.buildEditSession('sample.js'))
window.loadPackage('autocomplete')
autocomplete = new AutocompleteView(editor)
miniEditor = autocomplete.miniEditor

View File

@ -6,12 +6,11 @@ EditSession = require 'edit-session'
_ = require 'underscore'
describe "CommandInterpreter", ->
[project, interpreter, editSession, buffer] = []
[interpreter, editSession, buffer] = []
beforeEach ->
project = new Project(fixturesProject.resolve('dir/'))
interpreter = new CommandInterpreter(fixturesProject)
editSession = fixturesProject.buildEditSession('sample.js')
interpreter = new CommandInterpreter(project)
editSession = project.buildEditSession('sample.js')
buffer = editSession.buffer
afterEach ->
@ -418,7 +417,7 @@ describe "CommandInterpreter", ->
describe "X x/regex/", ->
it "returns selection operations for all regex matches in all the project's files", ->
editSession.destroy()
project = new Project(fixturesProject.resolve('dir/'))
project.setPath(project.resolve('dir'))
interpreter = new CommandInterpreter(project)
operationsToPreview = null

View File

@ -78,7 +78,7 @@ describe 'FuzzyFinder', ->
rootView.trigger 'fuzzy-finder:toggle-file-finder'
finderView.confirmed('dir/a')
expectedPath = fixturesProject.resolve('dir/a')
expectedPath = project.resolve('dir/a')
expect(finderView.hasParent()).toBeFalsy()
expect(editor1.getPath()).not.toBe expectedPath
@ -179,7 +179,7 @@ describe 'FuzzyFinder', ->
describe "when the active pane has an item for the selected path", ->
it "switches to the item for the selected path", ->
expectedPath = fixturesProject.resolve('sample.txt')
expectedPath = project.resolve('sample.txt')
finderView.confirmed('sample.txt')
expect(finderView.hasParent()).toBeFalsy()
@ -195,7 +195,7 @@ describe 'FuzzyFinder', ->
expect(rootView.getActiveView()).toBe editor1
expectedPath = fixturesProject.resolve('sample.txt')
expectedPath = project.resolve('sample.txt')
finderView.confirmed('sample.txt')
expect(finderView.hasParent()).toBeFalsy()

View File

@ -136,6 +136,6 @@ describe "GitHub Flavored Markdown grammar", ->
describe "auto indent", ->
it "indents newlines entered after list lines", ->
config.set('editor.autoIndent', true)
editSession = fixturesProject.buildEditSession('gfm.md')
editSession = project.buildEditSession('gfm.md')
editSession.insertNewlineBelow()
expect(editSession.buffer.lineForRow(1)).toBe ' '

View File

@ -300,7 +300,7 @@ describe "Snippets extension", ->
jasmine.unspy(LoadSnippetsTask.prototype, 'loadTextMateSnippets')
snippets.loaded = false
task = new LoadSnippetsTask(snippets)
task.packages = [Package.build(fixturesProject.resolve('packages/package-with-a-cson-grammar.tmbundle'))]
task.packages = [Package.build(project.resolve('packages/package-with-a-cson-grammar.tmbundle'))]
task.start()
waitsFor "CSON snippets to load", 5000, -> snippets.loaded