<commit_before>{Emitter} = require 'atom'
path = require 'path'

describe 'Jekyll Server', ->
  [jekyllServer, emitter, reply, activationPromise, editor, editorView] = []

  beforeEach ->
    atom.project.setPaths([path.join(__dirname, 'sample')])

    JekyllServer = require '../lib/server'
    emitter = new Emitter

    jekyllServer = new JekyllServer
    jekyllServer.activate(emitter)

    waitsForPromise ->
      atom.workspace.open('index.html')

    runs ->
      editor = atom.workspace.getActiveTextEditor()
      editorView = atom.views.getView(editor)

      atom.config.set('jekyll.serverOptions', ['serve', '-w'])
      atom.config.set('jekyll.jekyllBinary', 'jekyll')

  describe 'using emitters', ->
    it 'should return a status', ->
      spy = jasmine.createSpy()

      emitter.on 'jekyll:server-status-reply', spy
      emitter.emit 'jekyll:server-status'

      waitsFor ->
        spy.callCount > 0

      runs ->
        expect(spy.mostRecentCall.args[0]).toBe 'Off'

    it 'should start the server', ->
      expect(jekyllServer.rawStatus()).toBe 'Off'
      emitter.emit 'jekyll:start-server'
      expect(jekyllServer.rawStatus()).toBe 'On'
      emitter.emit 'jekyll:stop-server'
      expect(jekyllServer.rawStatus()).toBe 'Off'


  describe 'directly', ->
    it 'should start the server', ->
      expect(jekyllServer.rawStatus()).toBe 'Off'
      jekyllServer.start()
      expect(jekyllServer.rawStatus()).toBe 'On'
      jekyllServer.stop()
      expect(jekyllServer.rawStatus()).toBe 'Off'

    it 'should have loaded the PWD', ->
      expect(jekyllServer.pwd).toBe path.join(__dirname, 'sample')<commit_msg>fix the specs creating a silly number of ruby instances and causeing extreme processor usage and test the toggle command<commit_after>{Emitter} = require 'atom'
path = require 'path'

describe 'Jekyll Server', ->
  [jekyllServer, emitter, reply, activationPromise, editor, editorView] = []

  beforeEach ->
    atom.project.setPaths([path.join(__dirname, 'sample')])

    JekyllServer = require '../lib/server'

    unless jekyllServer
      emitter = new Emitter
      jekyllServer = new JekyllServer
      jekyllServer.activate(emitter)

    waitsForPromise ->
      atom.workspace.open('index.html')

    runs ->
      editor = atom.workspace.getActiveTextEditor()
      editorView = atom.views.getView(editor)

      atom.config.set('jekyll.serverOptions', ['serve', '-w'])
      atom.config.set('jekyll.jekyllBinary', 'jekyll')

  describe 'using emitters', ->
    it 'should return a status', ->
      spy = jasmine.createSpy()

      emitter.on 'jekyll:server-status-reply', spy
      emitter.emit 'jekyll:server-status'

      waitsFor ->
        spy.callCount > 0

      runs ->
        expect(spy.mostRecentCall.args[0]).toBe 'Off'

    it 'should start the server', ->
      waitsFor ->
        jekyllServer.rawStatus() == 'Off'

      runs ->
        emitter.emit 'jekyll:start-server'
        waitsFor ->
          jekyllServer.rawStatus() == 'On'
        runs ->
          expect(jekyllServer.rawStatus()).toBe 'On'
          emitter.emit 'jekyll:stop-server'


  describe 'directly', ->
    it 'should start the server', ->
      waitsFor ->
        jekyllServer.rawStatus() == 'Off'

      runs ->
        jekyllServer.start()
        expect(jekyllServer.rawStatus()).toBe 'On'
        jekyllServer.stop()
        expect(jekyllServer.rawStatus()).toBe 'Off'

    it 'should have loaded the PWD', ->
      expect(jekyllServer.pwd).toBe path.join(__dirname, 'sample')

  describe 'the toggle command', ->
    it 'should start the server if not running', ->
      waitsFor ->
        jekyllServer.rawStatus() == 'Off'

      runs ->
        jekyllServer.toggle()

        waitsFor ->
          jekyllServer.rawStatus() == 'On'

        runs ->
          expect(jekyllServer.rawStatus()).toBe 'On'
          jekyllServer.stop()
          expect(jekyllServer.rawStatus()).toBe 'Off'

    it 'should stop the server if it is running', ->
      waitsFor ->
        jekyllServer.rawStatus() == 'Off'

      runs ->
        jekyllServer.start()

        waitsFor ->
          jekyllServer.rawStatus() == 'On'

        runs ->
          expect(jekyllServer.rawStatus()).toBe 'On'
          jekyllServer.toggle()
          expect(jekyllServer.rawStatus()).toBe 'Off'
{'fraction_non_alphanumeric': 0.13432144511347846, 'fraction_numerical': 0.0009263547938860583, 'mean_word_length': 2.6385846672283066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 46, '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': '5967707', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1284, 'n_words': 275}