<commit_before>//
//  ElloAttributedStringSpec.swift
//  Ello
//
//  Created by <NAME> on 3/7/2015.
//  Copyright (c) 2015 Ello. All rights reserved.
//

import Ello
import Quick
import Nimble


class ElloAttributedStringSpec: QuickSpec {
    override func spec() {
        describe("styling a string") {
            it("returns an attributed string") {
                let text = "text"
                let attrd = ElloAttributedString.style(text)
                expect(attrd).to(beAKindOf(NSAttributedString))
            }
            it("accepts additional options") {
                let text = "text"
                let attrd = ElloAttributedString.style(text, [NSForegroundColorAttributeName: UIColor.grayColor()])
                expect(attrd).to(beAKindOf(NSAttributedString))
            }
        }

        describe("splitting a string") {
            it("preserves a string") {
                let attrd = ElloAttributedString.style("text")
                let splits = ElloAttributedString.split(attrd)
                expect(count(splits)) == 1
                expect((splits.safeValue(0) ?? NSAttributedString(string: "")).string) == "text"<commit_msg>ello attributed string specs<commit_after>//
//  ElloAttributedStringSpec.swift
//  Ello
//
//  Created by <NAME> on 3/7/2015.
//  Copyright (c) 2015 Ello. All rights reserved.
//

import Ello
import Quick
import Nimble


class ElloAttributedStringSpec: QuickSpec {
    override func spec() {
        describe("styling a string") {
            it("returns an attributed string") {
                let text = "text"
                let attrd = ElloAttributedString.style(text)
                expect(attrd).to(beAKindOf(NSAttributedString))
            }
            it("accepts additional options") {
                let text = "text"
                let c = UIColor.grayColor()
                let attrd = ElloAttributedString.style(text, [NSForegroundColorAttributeName: c])
                expect(attrd).to(beAKindOf(NSAttributedString))
                expect(attrd.attributesAtIndex(0, effectiveRange: nil)[NSForegroundColorAttributeName] as? UIColor) == c
            }
            it("ElloAttributedString.attrs() accepts many additional options") {
                let c1 = UIColor.lightGrayColor()
                let c2 = UIColor.darkGrayColor()
                let attrs1: [String: AnyObject] = [NSForegroundColorAttributeName: c1]
                let attrs2: [String: AnyObject] = [NSBackgroundColorAttributeName: c2]
                let attrs = ElloAttributedString.attrs(attrs1, attrs2)
                expect(attrs[NSForegroundColorAttributeName] as? UIColor) == c1
                expect(attrs[NSBackgroundColorAttributeName] as? UIColor) == c2
            }
        }

        describe("splitting a string") {
            it("preserves a string") {
                let attrd = ElloAttributedString.style("text")
                let splits = ElloAttributedString.split(attrd)
                expect(count(splits)) == 1
                expect((splits.safeValue(0) ?? NSAttributedString(string: "")).string) == "text"
{'fraction_non_alphanumeric': 0.10480490164463076, 'fraction_numerical': 0.011286681715575621, 'mean_word_length': 2.127016129032258, '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': '4729625', 'n_tokens_mistral': 921, 'n_tokens_neox': 855, 'n_words': 188}