Fix showing of options when a test fails when running specs

This commit is contained in:
Glavin Wiechert 2015-06-10 17:30:44 -03:00
parent 01d7f2f9bb
commit 68070d5b4b
2 changed files with 12 additions and 6 deletions

View File

@ -150,6 +150,9 @@ describe "BeautifyLanguages", ->
# Get the options
allOptions = beautifier.getOptionsForPath(originalTestPath)
# Get language
language = beautifier.getLanguage(grammarName, testFileName)
beautifyCompleted = false
completionFun = (text) ->
# Replace Newlines
@ -185,8 +188,9 @@ describe "BeautifyLanguages", ->
newHeader="expected"
diff = JsDiff.createPatch(fileName, oldStr, \
newStr, oldHeader, newHeader)
opts = beautifier.getOptions(allOptions, \
grammarName, testFileName)
# Get options
opts = beautifier.getOptionsForLanguage(allOptions, language)
# Show error message with debug information
expect(text).toEqual(expectedContents, \
"Beautifier output does not match expected \
output:\n#{diff}\n\n\

View File

@ -289,7 +289,7 @@ module.exports = class Beautifiers extends EventEmitter
_.contains(beautifier.languages, language)
)
getOptions : (allOptions, grammar, filePath) ->
getLanguage : (grammar, filePath) ->
# Get language
fileExtension = path.extname(filePath)
# Remove prefix "." (period) in fileExtension
@ -302,9 +302,11 @@ module.exports = class Beautifiers extends EventEmitter
else
# TODO: select appropriate language
language = languages[0]
# Options for Language
options = @getOptions([language.namespace]\
.concat(language.fallback or []), allOptions) or {}
getOptionsForLanguage : (allOptions, language) ->
# Options for Language
options = @getOptions([language.namespace]\
.concat(language.fallback or []), allOptions) or {}
beautify : (text, allOptions, grammar, filePath, {onSave} = {}) ->
return Promise.all(allOptions)