From 68070d5b4bb7b8bd37100e62d99ab02de65bb019 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Wed, 10 Jun 2015 17:30:44 -0300 Subject: [PATCH] Fix showing of options when a test fails when running specs --- spec/beautify-languages-spec.coffee | 8 ++++++-- src/beautifiers/index.coffee | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/beautify-languages-spec.coffee b/spec/beautify-languages-spec.coffee index 6bf0e0f..c23f51a 100644 --- a/spec/beautify-languages-spec.coffee +++ b/spec/beautify-languages-spec.coffee @@ -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\ diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index c854e20..22743ca 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -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)