<commit_before>//
//  EventsSpec.swift
//  SwiftHub
//
//  Created by <NAME> on 8/5/15.
//  Copyright © 2015 phatblat. All rights reserved.
//

@testable import SwiftHub
import Quick
import Nimble

class EventsSpec: QuickSpec {
    override func spec() {
        describe("events list") {
            it("can be retrieved") {
                let semaphore = dispatch_semaphore_create(0)

                Events.list() { (events: [String]?) in
                    XCTAssertNotNil(events)
                    print("events \(events)")
                    dispatch_semaphore_signal(semaphore)
                }

                dispatch_semaphore_wait(semaphore, 10 * NSEC_PER_SEC)
            }
        }
    }
}<commit_msg>Fix timeout, add expectations<commit_after>//
//  EventsSpec.swift
//  SwiftHub
//
//  Created by <NAME> on 8/5/15.
//  Copyright © 2015 phatblat. All rights reserved.
//

@testable import SwiftHub
import Quick
import Nimble

class EventsSpec: QuickSpec {
    var events: [String]?
    
    override func spec() {
        describe("events list") {
            it("can be retrieved") {
                guard let semaphore = dispatch_semaphore_create(0)
                else { fatalError("Failed to create semaphore") }

                Events.list() { (events: [String]?) in
                    expect(events).toNot(beNil())
                    print("events \(events)")
                    self.events = events

                    dispatch_semaphore_signal(semaphore)
                }

                let timeout = dispatch_time(DISPATCH_TIME_NOW, Int64(10 * NSEC_PER_SEC))
                dispatch_semaphore_wait(semaphore, timeout)
                
                expect(self.events).toNot(beNil())
                expect(self.events?.count).to(equal(30))
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10578512396694215, 'fraction_numerical': 0.014325068870523415, 'mean_word_length': 1.6903703703703703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1856447', 'n_tokens_mistral': 567, 'n_tokens_neox': 513, 'n_words': 114}