<commit_before>// https://github.com/Quick/Quick

import Quick
import Nimble
import AirRivet
import Foundation

class Mock: Environment, Mockable, Transformable {
	var serverUrl = ""
	var request = NSMutableURLRequest()

	func shouldMock() -> Bool {
		return true
	}
}

class MockGameScore: GameScore {

	override func contextPath() -> String {
		return "gameScoreArray"
	}

	override func environment() -> protocol<Environment, Mockable, Transformable> {
		return Mock ()
	}
}

class GameScoreSpec: QuickSpec {
    override func spec() {
        describe("GameScore") {


			it ("Should be synchronous because we implement the Mockable protocol") {
				var result = [MockGameScore]()
				try! RequestController().retrieve({ (response) in
					result = response
				})
				expect(result).to(haveCount(5))
			}

			it("all gamescores should be parsed", closure: {
				var result = [MockGameScore]()
				let expected = ["Bob", "Daniel", "Hans", "Stijn", "Jelle"]
				try! RequestController().retrieve({ (response) in
					result = response

				})
				for i in 0..<result.count {
					let gameScore = result[i]
					expect(gameScore.playerName).to(equal(expected[i]))
				}
			})
            it("save succeeds by mocking") {

				var success = false
				let gameScore = MockGameScore()
				gameScore.score = 1
				gameScore.cheatMode = false
				gameScore.playerName = "Foo"
				
				try! RequestController().save(gameScore, completion: { (response) in
					success = true
					})
				expect(success).to(equal(true))
            }

			it("retrieve a single gamescore by objectID"){

				var result = MockGameScore()<commit_msg>By defining type we get the response we want<commit_after>// https://github.com/Quick/Quick

import Quick
import Nimble
import AirRivet
import Foundation

class Mock: Environment, Mockable, Transformable {
	var serverUrl = ""
	var request = NSMutableURLRequest()

	func shouldMock() -> Bool {
		return true
	}
}

class MockGameScore: GameScore {

	override func contextPath() -> String {
		return "gameScoreArray"
	}

	override func environment() -> protocol<Environment, Mockable, Transformable> {
		return Mock ()
	}
}

class GameScoreSpec: QuickSpec {
    override func spec() {
        describe("GameScore") {


			it ("Should be synchronous because we implement the Mockable protocol") {

				try! RequestController().retrieve(completion: { (response: [MockGameScore]) in
					expect(response).to(haveCount(5))
				})
			}

			it("all gamescores should be parsed", closure: {
				let expected = ["Bob", "Daniel", "Hans", "Stijn", "Jelle"]
				try! RequestController().retrieve(completion: { (response: [MockGameScore]) in
					for i in 0..<response.count {
						let gameScore = response[i]
						expect(gameScore.playerName).to(equal(expected[i]))
					}
				})

			})
            it("save succeeds by mocking") {

				var success = false
				let gameScore = MockGameScore()
				gameScore.score = 1
				gameScore.cheatMode = false
				gameScore.playerName = "Foo"
				
				try! RequestController().save(gameScore, completion: { (response) in
					success = true
					})
				expect(success).to(equal(true))
            }

			it("retrieve a single gamescore by objectID"){

				var result = MockGameScore()
{'fraction_non_alphanumeric': 0.11993817619783617, 'fraction_numerical': 0.0018547140649149924, 'mean_word_length': 3.2747688243064728, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '4419063', 'n_tokens_mistral': 1167, 'n_tokens_neox': 930, 'n_words': 263}