Merge branch 'master' into wip

This commit is contained in:
Nathan Sobo 2011-12-23 15:58:11 -06:00
commit 68ce5544a7
5 changed files with 62 additions and 12 deletions

View File

@ -27,3 +27,9 @@ task :install do
rm_rf "/Applications/Atomicity.app"
cp_r "Cocoa/build/Debug/Atomicity.app /Applications"
end
desc "Remove any 'fit' or 'fdescribe' focus directives from the specs"
task :nof do
system %{find . -name *spec.coffee | xargs sed -E -i "" "s/f(it|describe) +(['\\"])/\\1 \\2/g"}
end

View File

@ -35,25 +35,30 @@ describe "Editor", ->
expect(mainDiv.children('.editor').length).toBe 0
describe "open(url)", ->
it "sets the mode on the session", ->
editor.open('something.js')
expect(editor.aceEditor.getSession().getMode().name).toBe 'javascript'
editor.open('something.text')
expect(editor.aceEditor.getSession().getMode().name).toBe 'text'
describe "when called with a url", ->
it "loads a buffer for the given url into the editor", ->
editor.open(filePath)
fileContents = fs.read(filePath)
expect(editor.aceEditor.getSession().getValue()).toBe fileContents
expect(editor.getAceSession().getValue()).toBe fileContents
expect(editor.buffer.url).toBe(filePath)
expect(editor.buffer.getText()).toEqual fileContents
it "sets the mode on the session based on the file extension", ->
editor.open('something.js')
expect(editor.getAceSession().getMode().name).toBe 'javascript'
editor.open('something.text')
expect(editor.getAceSession().getMode().name).toBe 'text'
it "assigns the url on the $atomController global", ->
expect($atomController.url).toBeNull()
editor.open(filePath)
expect($atomController.url.toString()).toEqual(filePath)
describe "when called with null", ->
it "loads an empty buffer with no url", ->
editor.open()
expect(editor.aceEditor.getSession().getValue()).toBe ""
expect(editor.getAceSession().getValue()).toBe ""
expect(editor.buffer.url).toBeUndefined()
expect(editor.buffer.getText()).toEqual ""
@ -61,7 +66,7 @@ describe "Editor", ->
it "updates the buffer text", ->
editor.open(filePath)
expect(editor.buffer.getText()).not.toMatch /^.ooo/
editor.aceEditor.getSession().insert {row: 0, column: 1}, 'ooo'
editor.getAceSession().insert {row: 0, column: 1}, 'ooo'
expect(editor.buffer.getText()).toMatch /^.ooo/
describe "save", ->

View File

@ -1,5 +1,6 @@
nakedLoad 'jasmine'
nakedLoad 'jasmine-html'
nakedLoad 'jasmine-focused'
$ = require 'jquery'
coffeekup = require 'coffeekup'
@ -16,8 +17,7 @@ trivialReporter = new jasmine.TrivialReporter(document, 'jasmine_runner')
jasmineEnv.addReporter(trivialReporter)
jasmineEnv.specFilter = (spec) ->
return trivialReporter.specFilter(spec)
jasmineEnv.specFilter = (spec) -> trivialReporter.specFilter(spec)
require 'spec-suite'
jasmineEnv.execute()

View File

@ -20,6 +20,7 @@ class Editor
@aceEditor.destroy()
open: (url) ->
$atomController.url = url
@buffer = new Buffer(url)
session = new EditSession(@buffer.aceDocument, @buffer.getMode())
@aceEditor.setSession(session)

38
vendor/jasmine-focused.js vendored Normal file
View File

@ -0,0 +1,38 @@
var fdescribe = function(description, specDefinitions) {
jasmine.getEnv().focus = true
var suite = describe(description, specDefinitions);
suite.focus = true;
return suite;
};
var fit = function(description, definition) {
jasmine.getEnv().focus = true
var spec = it(description, definition);
spec.focus = true;
return spec;
};
var fSpecFilter = function(specOrSuite) {
if (!jasmine.getEnv().focus) return true;
if (specOrSuite.focus) return true;
var parent = specOrSuite.parentSuite || specOrSuite.suite;
if (!parent) return false;
return fSpecFilter(parent);
}
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
var paramMap = {};
var params = this.getLocation().search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
if (!paramMap.spec && !jasmine.getEnv().focus) {
return true;
}
return (spec.getFullName().indexOf(paramMap.spec) === 0) || fSpecFilter(spec);
};