<commit_before>//
//  CoreDataEntitySpec.swift
//  AirRivet
//
//  Created by <NAME> on 19/05/16.
//  Copyright © 2016 CocoaPods. All rights reserved.
//

import Foundation
import Quick
import Nimble
import CoreData

@testable import AirRivet_Example


// MARK: - Specs

class CoreDataEntitySpec: QuickSpec {

	override func spec() {
		describe("Create core data") {

			let coreDataController = CoreDataController.sharedInstance
			coreDataController.storeType = NSInMemoryStoreType
			beforeEach({
				coreDataController.managedObjectContext.reset()
			})

			it("Create instanse with username") {
				let entity = try! CoreDataEntity(json: ["username": "Fons"], managedObjectContext: coreDataController.managedObjectContext)
				expect(entity.username).to(equal("Fons"))
			}

			it("should fetch an existing object") {
				let json = ["CoreDataEntityObjectId":"unique id", "username": "Fons"]
				let entity = try! CoreDataEntity(json: json, managedObjectContext: coreDataController.managedObjectContext)

				let sameEntity = try! CoreDataEntity.lookupExistingObjectFromJSON(json, managedObjectContext: coreDataController.managedObjectContext)

				expect(entity.objectID).to(equal(sameEntity?.objectID))

				//TODO: fetch all entities and see if there are only 1

				//TODO: let init fail if there is a unique object present

				

			}
		}
	}
<commit_msg>Added count test and some todo’s<commit_after>//
//  CoreDataEntitySpec.swift
//  AirRivet
//
//  Created by <NAME> on 19/05/16.
//  Copyright © 2016 CocoaPods. All rights reserved.
//

import Foundation
import Quick
import Nimble
import CoreData

@testable import AirRivet_Example


// MARK: - Specs

class CoreDataEntitySpec: QuickSpec {

	override func spec() {
		describe("Create core data") {

			let coreDataController = CoreDataController.sharedInstance
			coreDataController.storeType = NSInMemoryStoreType
			beforeEach({
				coreDataController.managedObjectContext.reset()
			})

			it("Create instanse with username") {
				let entity = try! CoreDataEntity(json: ["username": "Fons"], managedObjectContext: coreDataController.managedObjectContext)
				expect(entity.username).to(equal("Fons"))
			}

			it("should fetch an existing object") {
				let json = ["CoreDataEntityObjectId":"unique id", "username": "Fons"]
				let entity = try! CoreDataEntity(json: json, managedObjectContext: coreDataController.managedObjectContext)

				let sameEntity = try! CoreDataEntity.lookupExistingObjectFromJSON(json, managedObjectContext: coreDataController.managedObjectContext)

				expect(entity.objectID).to(equal(sameEntity?.objectID))

				let fetch = NSFetchRequest(entityName: "CoreDataEntity")
				let allEntities = try! coreDataController.managedObjectContext.executeFetchRequest(fetch) as! [CoreDataEntity]

				expect(allEntities).to(haveCount(1))

				//TODO: let init fail if there is a unique object present

				//TODO: Test with transformer

			}
		}
	}

{'fraction_non_alphanumeric': 0.10187393526405451, 'fraction_numerical': 0.007495741056218058, 'mean_word_length': 4.447124304267161, 'pattern_counts': {'":': 6, '<': 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': '2266779', 'n_tokens_mistral': 982, 'n_tokens_neox': 829, 'n_words': 217}