mas/MasKitTests/OutputListenerSpec.swift
2021-03-28 14:21:14 -07:00

48 lines
1.3 KiB
Swift

//
// OutputListenerSpec.swift
// MasKitTests
//
// Created by Ben Chatelain on 1/8/19.
// Copyright © 2019 mas-cli. All rights reserved.
//
import Nimble
import Quick
class OutputListenerSpec: QuickSpec {
override func spec() {
xdescribe("output listener") {
it("can intercept a single line written stdout") {
let output = OutputListener()
output.openConsolePipe()
let expectedOutput = "hi there"
print("hi there", terminator: "")
// output is async so need to wait for contents to be updated
expect(output.contents).toEventuallyNot(beEmpty())
expect(output.contents) == expectedOutput
output.closeConsolePipe()
}
it("can intercept multiple lines written stdout") {
let output = OutputListener()
output.openConsolePipe()
let expectedOutput = """
hi there
"""
print("hi there")
// output is async so need to wait for contents to be updated
expect(output.contents).toEventuallyNot(beEmpty())
expect(output.contents) == expectedOutput
output.closeConsolePipe()
}
}
}
}