       atom.config.set('foo.bar.baz', "value 10")
       expect(bazCatHandler).not.toHaveBeenCalled()
 
-    describe "observing scoped settings", ->
+    describe "when a 'scope' is given", ->
       otherHandler = null
 
       beforeEach ->

        atom.config.set('foo.changes', 1)
        expect(atom.config.get("foo.changes", sources: [atom.config.getUserConfigPath()])).toBeUndefined()

  describe ".getDefault(keyPath)", ->
    it "returns a clone of the default value", ->
      atom.config.setDefaults("foo", same: 1, changes: 1)

      spyOn(Grim, 'deprecate')
      expect(atom.config.getDefault('foo.same')).toBe 1
      expect(atom.config.getDefault('foo.changes')).toBe 1
      expect(Grim.deprecate.callCount).toBe 2

      atom.config.set('foo.same', 2)
      atom.config.set('foo.changes', 3)

      expect(atom.config.getDefault('foo.same')).toBe 1
      expect(atom.config.getDefault('foo.changes')).toBe 1
      expect(Grim.deprecate.callCount).toBe 4

      initialDefaultValue = [1, 2, 3]
      atom.config.setDefaults("foo", bar: initialDefaultValue)
      expect(atom.config.getDefault('foo.bar')).toEqual initialDefaultValue
      expect(atom.config.getDefault('foo.bar')).not.toBe initialDefaultValue
      expect(Grim.deprecate.callCount).toBe 6

    describe "when scoped settings are used", ->
      it "returns the global default when no scoped default set", ->
        atom.config.setDefaults("foo", bar: baz: 10)

        spyOn(Grim, 'deprecate')
        expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 10
        expect(Grim.deprecate).toHaveBeenCalled()

      it "returns the scoped settings not including the user's config file", ->
        atom.config.setDefaults("foo", bar: baz: 10)
        atom.config.addScopedSettings("default", ".source.coffee", foo: bar: baz: 42)

        spyOn(Grim, 'deprecate')
        expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42
        expect(Grim.deprecate.callCount).toBe 1

        atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee')
        expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42
        expect(Grim.deprecate.callCount).toBe 2

  describe ".isDefault(keyPath)", ->
    it "returns true when the value of the key path is its default value", ->
      atom.config.setDefaults("foo", same: 1, changes: 1)

      spyOn(Grim, 'deprecate')
      expect(atom.config.isDefault('foo.same')).toBe true
      expect(atom.config.isDefault('foo.changes')).toBe true
      expect(Grim.deprecate.callCount).toBe 2

      atom.config.set('foo.same', 2)
      atom.config.set('foo.changes', 3)

      expect(atom.config.isDefault('foo.same')).toBe false
      expect(atom.config.isDefault('foo.changes')).toBe false
      expect(Grim.deprecate.callCount).toBe 4

    describe "when scoped settings are used", ->
      it "returns false when a scoped setting was set by the user", ->
        spyOn(Grim, 'deprecate')
        expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true
        expect(Grim.deprecate.callCount).toBe 1

        atom.config.addScopedSettings("default", ".source.coffee", foo: bar: baz: 42)
        expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true
        expect(Grim.deprecate.callCount).toBe 2

        atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee')
        expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe false
        expect(Grim.deprecate.callCount).toBe 3

  describe ".setDefaults(keyPath)", ->
    it "sets a default when the setting's key contains an escaped dot", ->
      atom.config.setDefaults("foo", 'a\\.b': 1, b: 2)
      expect(atom.config.get("foo")).toEqual 'a\\.b': 1, b: 2

  describe ".toggle(keyPath)", ->
    beforeEach ->
      jasmine.snapshotDeprecations()

    afterEach ->
      jasmine.restoreDeprecationsSnapshot()

    it "negates the boolean value of the current key path value", ->
      atom.config.set('foo.a', 1)
      atom.config.toggle('foo.a')
      expect(atom.config.get('foo.a')).toBe false

      atom.config.set('foo.a', '')
      atom.config.toggle('foo.a')
      expect(atom.config.get('foo.a')).toBe true

      atom.config.set('foo.a', null)
      atom.config.toggle('foo.a')
      expect(atom.config.get('foo.a')).toBe true

      atom.config.set('foo.a', true)
      atom.config.toggle('foo.a')
      expect(atom.config.get('foo.a')).toBe false

  describe ".unset(keyPath, {scope})", ->
    it "sets the value of the key path to its default", ->
      atom.config.setDefaults('a', b: 3)
      atom.config.set('a.b', 4)

        expect(observeHandler).toHaveBeenCalledWith("value 2")
        expect(otherHandler).not.toHaveBeenCalledWith("value 2")

      it 'calls the callback when properties with more specific selectors are removed', ->
        changeSpy = jasmine.createSpy()
        atom.config.observe("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"], changeSpy)
        expect(changeSpy).toHaveBeenCalledWith("value 1")
        changeSpy.reset()

        atom.config.set("foo.bar.baz", 12)
        expect(changeSpy).toHaveBeenCalledWith(12)
        changeSpy.reset()

        disposable1 = atom.config.addScopedSettings("a", ".source .string.quoted.double", foo: bar: baz: 22)
        expect(changeSpy).toHaveBeenCalledWith(22)
        changeSpy.reset()

        disposable2 = atom.config.addScopedSettings("b", ".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
        expect(changeSpy).toHaveBeenCalledWith(42)
        changeSpy.reset()

        disposable2.dispose()
        expect(changeSpy).toHaveBeenCalledWith(22)
        changeSpy.reset()

        disposable1.dispose()
        expect(changeSpy).toHaveBeenCalledWith(12)
        changeSpy.reset()

        atom.config.set("foo.bar.baz", undefined)
        expect(changeSpy).toHaveBeenCalledWith(undefined)
        changeSpy.reset()

  describe ".transact(callback)", ->
    changeSpy = null

