<commit_before># should move pre-existing readme on start, and back into place when done

vows    = require 'vows'
assert  = require 'assert'
_       = require 'underscore'
config  = require '../src/config'

vows
  .describe('Config')

  .addBatch
    'Reset Config': 
      topic: -> 
        new config.Config
      
      'when we do c.reset()':
        topic: (config) -> 
          config.reset()
        
        'returns an object': (config) ->
          assert.equal _.isObject(config), true

  .addBatch
    'Create a new Config':
      topic: -> 
        new config.Config
      

      'and we do c.getHostname(http://example.com)':
        topic: (config) -> 
          config.getHostname 'http://example.com'
        
        'returns false': (config) ->
            assert.equal config, false

        'and we do c.addHostname(http://example.com)':
          topic: (file, config) -> 
            config.addHostname 'http://example.com'
          
          'returns an array': (config) ->
            assert.equal _.isArray(config), true

          'returns an empty list of plugins': (config) ->
            assert.equal _.size(config), 0

          'and then access it using c.getHostname(http://example.com)':
              topic: (host, file, config) -> 
                config.getHostname 'http://example.com'
              
              'returns an array': (config) ->
                assert.equal _.isArray(config), true

              'returns an empty list of plugins': (config) ->
                assert.equal _.size(config), 0

  .addBatch
    'Add a plugin':
      topic: -> 
        new config.Config
      
      'when we do c.addPlugin(spell-check)':
        topic: (config) -> 
          config.addHostname 'http://example.com'
          config.addPlugin 'http://example.com', 'spell-check', {}
        
        'returns an array of plugins': (plugins) ->
          assert.equal _.isArray(plugins), true

        'returns an empty array of plugins': (plugins) ->
          assert.equal _.size(plugins), 1

        'when we do c.getPlugin(spell-check)':
          topic: (plugin, config) -> 
            config.getPlugin 'http://example.com', 'spell-check'

          'plugins contains the "spell-check" plugin': (plugin) ->
            assert.equal plugin.name, 'spell-check'

          'the "spell-check" plugin has options': (plugin) ->
            assert.equal plugin.hasOwnProperty('opts'), true

          'the "spell-check" plugin options is an object': (plugin) ->
            assert.equal _.isObject(plugin.opts), true

 .addBatch
    'Save a Config to filesystem':
      topic: -> 
        new config.Config
      
      'when we do c.save()':
        topic: (config) -> 
          config.open()
          config.addHostname 'http://example.com'
          config.save()
        
        'returns an object': (config) ->
          assert.equal _.isObject(config), true

        'returns a single hostname': (config) ->
          assert.equal _.size(config), 1

        'hostname points to an array of plugins': (config) ->
          assert.equal _.isArray(config['example.com']), true<commit_msg>Added test of saving a Config to filesystem<commit_after># should move pre-existing readme on start, and back into place when done

vows    = require 'vows'
assert  = require 'assert'
_       = require 'underscore'
config  = require '../src/config'

vows
  .describe('Config')

  .addBatch
    'Reset Config': 
      topic: -> 
        new config.Config
      
      'when we do c.reset()':
        topic: (config) -> 
          config.reset()
        
        'returns an object': (config) ->
          assert.equal _.isObject(config), true

  .addBatch
    'Create a new Config':
      topic: -> 
        new config.Config

      'and we do c.getHostname(http://example.com)':
        topic: (config) -> 
          config.getHostname 'http://example.com'
        
        'returns false': (config) ->
            assert.equal config, false

        'and we do c.addHostname(http://example.com)':
          topic: (file, config) -> 
            config.addHostname 'http://example.com'
          
          'returns an array': (config) ->
            assert.equal _.isArray(config), true

          'returns an empty list of plugins': (config) ->
            assert.equal _.size(config), 0

          'and then access it using c.getHostname(http://example.com)':
              topic: (host, file, config) -> 
                config.getHostname 'http://example.com'
              
              'returns an array': (config) ->
                assert.equal _.isArray(config), true

              'returns an empty list of plugins': (config) ->
                assert.equal _.size(config), 0

  .addBatch
    'Add a plugin':
      topic: -> 
        new config.Config
      
      'when we do c.addPlugin(spell-check)':
        topic: (config) -> 
          config.addHostname 'http://example.com'
          config.addPlugin 'http://example.com', 'spell-check', {}
        
        'returns an array of plugins': (plugins) ->
          assert.equal _.isArray(plugins), true

        'returns an empty array of plugins': (plugins) ->
          assert.equal _.size(plugins), 1

        'when we do c.getPlugin(spell-check)':
          topic: (plugin, config) -> 
            config.getPlugin 'http://example.com', 'spell-check'

          'plugins contains the "spell-check" plugin': (plugin) ->
            assert.equal plugin.name, 'spell-check'

          'the "spell-check" plugin has options': (plugin) ->
            assert.equal plugin.hasOwnProperty('opts'), true

          'the "spell-check" plugin options is an object': (plugin) ->
            assert.equal _.isObject(plugin.opts), true

.addBatch
    'Save a Config to filesystem':
      topic: -> 
        new config.Config
      
      'when we do c.save()':
        topic: (config) -> 
          config.addHostname 'http://example.com'
          config.save()
        
        'returns an object': (config) ->
          assert.equal _.isObject(config), true

        'returns a single hostname': (config) ->
          assert.equal _.size(config), 1

        'hostname points to an array of plugins': (config) ->
          assert.equal _.isArray(config['example.com']), true
{'fraction_non_alphanumeric': 0.12902711323763955, 'fraction_numerical': 0.0012759170653907496, 'mean_word_length': 1.782165039929015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2191921', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1738, 'n_words': 493}