Applying a grammar to a buffer for Spec testing


Is there a way to apply a grammar to a buffer inside a Jasmine test? I have a package that depends on detecting code block from the scope applied to text, but I cant build an automated test because the buffer doesn’t appear to have scopes in the Jasmine test.


Have you activated the language package for the grammar ?

p = atom.packages.activatePackage('language-c')
waitsForPromise -> p

To set the grammar of a TextEditor you can do:

grammar = atom.grammars.grammarForScopeName('source.c')