<commit_before>//
//  MessageBrokerSpec.swift
//  MessageBroker
//
//  Created by <NAME> on 03/09/2014.
//  Copyright (c) 2014 CocoaFlow. All rights reserved.
//

import Foundation
import Quick
import Nimble
import MessageBroker
import JSONLib

class MessageBrokerSpec: QuickSpec {
    
    override func spec() {
        
        describe("Message broker") {
            
            describe("receiving a message") {
                
                it("should forward the message to the message receiver") {
                    let messageBroker = MessageBroker()
                    
                    let brokerChannel = "channel"
                    let brokerTopic = "topic"
                    let brokerPayload = "{\"key\":\"value\"}"
                    
                    var receiverChannel: String!
                    var receiverTopic: String!
                    var receiverPayload: JSON!
                    
                    let messageReceiver = FakeMessageReceiver(messageBroker) { (channel, topic, payload) in
                        receiverChannel = channel
                        receiverTopic = topic
                        receiverPayload = payload
                    }
                    
                    messageBroker.receive(brokerChannel, brokerTopic, JSON.parse(brokerPayload).value!)
                    
                    expect(receiverChannel).to(equal(brokerChannel))
                    expect(receiverTopic).to(equal(brokerTopic))
                    expect(receiverPayload).to(equal(JSON.parse(brokerPayload).value))
                }
            }
            
            describe("sending a message") {
                
                it("should forward the message to the message sender") {
                    let messageBroker = MessageBroker()
                    
                    let brokerChannel = "channel"
                    let brokerTopic = "topic"
                    let brokerPayload = "{\"key\":\"value\"}"
                    
                    var receiverChannel: String!
                    var receiverTopic: String!
                    var receiverPayload: JSON!
                    
                    let messageReceiver = FakeMessageSender(messageBroker) { (channel, topic, payload) in
                        receiverChannel = channel
                        receiverTopic = topic
                        receiverPayload = payload
                    }
                    
                    messageBroker.send(brokerChannel, brokerTopic, JSON.parse(brokerPayload).value!)
                    
                    expect(receiverChannel).to(equal(brokerChannel))
                    expect(receiverTopic).to(equal(brokerTopic))
                    expect(receiverPayload).to(equal(JSON.parse(brokerPayload).value))
                }
            }
        }
    }
}<commit_msg>Fix variable and constant names in spec example.<commit_after>//
//  MessageBrokerSpec.swift
//  MessageBroker
//
//  Created by <NAME>ung on 03/09/2014.
//  Copyright (c) 2014 CocoaFlow. All rights reserved.
//

import Foundation
import Quick
import Nimble
import MessageBroker
import JSONLib

class MessageBrokerSpec: QuickSpec {
    
    override func spec() {
        
        describe("Message broker") {
            
            describe("receiving a message") {
                
                it("should forward the message to the message receiver") {
                    let messageBroker = MessageBroker()
                    
                    let brokerChannel = "channel"
                    let brokerTopic = "topic"
                    let brokerPayload = "{\"key\":\"value\"}"
                    
                    var receiverChannel: String!
                    var receiverTopic: String!
                    var receiverPayload: JSON!
                    
                    let messageReceiver = FakeMessageReceiver(messageBroker) { (channel, topic, payload) in
                        receiverChannel = channel
                        receiverTopic = topic
                        receiverPayload = payload
                    }
                    
                    messageBroker.receive(brokerChannel, brokerTopic, JSON.parse(brokerPayload).value!)
                    
                    expect(receiverChannel).to(equal(brokerChannel))
                    expect(receiverTopic).to(equal(brokerTopic))
                    expect(receiverPayload).to(equal(JSON.parse(brokerPayload).value))
                }
            }
            
            describe("sending a message") {
                
                it("should forward the message to the message sender") {
                    let messageBroker = MessageBroker()
                    
                    let brokerChannel = "channel"
                    let brokerTopic = "topic"
                    let brokerPayload = "{\"key\":\"value\"}"
                    
                    var senderChannel: String!
                    var senderTopic: String!
                    var senderPayload: JSON!
                    
                    let messageSender = FakeMessageSender(messageBroker) { (channel, topic, payload) in
                        senderChannel = channel
                        senderTopic = topic
                        senderPayload = payload
                    }
                    
                    messageBroker.send(brokerChannel, brokerTopic, JSON.parse(brokerPayload).value!)
                    
                    expect(senderChannel).to(equal(brokerChannel))
                    expect(senderTopic).to(equal(brokerTopic))
                    expect(senderPayload).to(equal(JSON.parse(brokerPayload).value))
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07514751822283929, 'fraction_numerical': 0.004165220409580007, 'mean_word_length': 1.1954285714285715, 'pattern_counts': {'":': 4, '<': 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': '5313354', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1195, 'n_words': 277}