 
   describe "when the edit session is destroyed", ->
     beforeEach ->
-      config.set("whitespace.ensureSingleTrailingNewline", false)
+      atom.config.set("whitespace.ensureSingleTrailingNewline", false)
 
       buffer.retain()
       editor.destroy()


  beforeEach ->
    directory = temp.mkdirSync()
    project.setPath(directory)
    filePath = path.join(directory, 'atom-whitespace.txt')
    fs.writeFileSync(filePath, '')
    fs.writeFileSync(path.join(directory, 'sample.txt'), 'Some text.\n')
    editor = project.openSync(filePath)
    buffer = editor.getBuffer()

    atom.activatePackage('whitespace')

  it "strips trailing whitespace before an editor saves a buffer", ->
    config.set("whitespace.ensureSingleTrailingNewline", false)

    # works for buffers that are already open when extension is initialized
    editor.insertText("foo   \nbar\t   \n\nbaz")

    grammar = null

    beforeEach ->
      spyOn(atom.syntax, "addGrammar").andCallThrough()
      atom.packages.activatePackage("language-gfm", sync: true)
      expect(atom.syntax.addGrammar).toHaveBeenCalled()
      grammar = atom.syntax.addGrammar.argsForCall[0][0]

    it "trims GFM text with a single space", ->
      editor.setGrammar(grammar)
