Skip to content

Commit

Permalink
Merge pull request #10 from gperdomor/vapor-2
Browse files Browse the repository at this point in the history
fix for vapor 2
  • Loading branch information
BrettRToomey authored May 29, 2017
2 parents 4e0f537 + 53005a3 commit cba7bae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 86 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription
let package = Package(
name: "BML",
dependencies: [
.Package(url: "https://github.com/vapor/core.git", majorVersion: 1),
.Package(url: "https://github.com/vapor/node.git", majorVersion: 1)
.Package(url: "https://github.com/vapor/core.git", majorVersion: 2),
.Package(url: "https://github.com/vapor/node.git", majorVersion: 2)
]
)
2 changes: 1 addition & 1 deletion Sources/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extension XMLParser {
}

guard token == .greaterThan else {
throw Error.malformedXML("Expected `>` for tag: \(name.string)")
throw Error.malformedXML("Expected `>` for tag: \(name.makeString())")
}

// >
Expand Down
83 changes: 0 additions & 83 deletions Tests/BMLTests/BMLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,86 +366,3 @@ extension BML {

}
}

extension Node {
func expect(
objects expectedObjects: [String],
file: StaticString = #file,
line: UInt = #line
) {
if case .object(var rootObjects) = self {
expectedObjects.forEach {
XCTAssertNotNil(rootObjects[$0], file: file, line: line)
rootObjects.removeValue(forKey: $0)
}

rootObjects.forEach {
XCTFail("Extra, unexpected object: \($0.key)", file: file, line: line)
}
} else {
XCTFail("Expected root object")
}
}

func expect(
fields expectedFields: [String: NodeRepresentable],
file: StaticString = #file,
line: UInt = #line
) {
if case .object(var rootObjects) = self {
expectedFields.forEach {
if let field = rootObjects[$0.key] {
XCTAssertEqual(
field, try! $0.value.makeNode(),
file: file, line: line
)
} else {
XCTFail("Expected key: \($0.key)", file: file, line: line)
}

rootObjects.removeValue(forKey: $0.key)
}

rootObjects.forEach {
XCTFail("Extra, unexpected field: \($0.key)", file: file, line: line)
}
} else {
XCTFail("Expected root object")
}
}

func expectObject(
named name: String,
containing expected: [(String, NodeRepresentable)],
file: StaticString = #file,
line: UInt = #line
) {
if let entry = self[name] , case .object(var object) = entry {
expected.forEach { key, expectedValue in
if let value = object[key] {
XCTAssertEqual(
value,
try! expectedValue.makeNode(),
file: file,
line: line
)

object.removeValue(forKey: key)

} else {
XCTFail(
"Expected value \(expectedValue) for \"\(key)\" in \(name)",
file: file,
line: line
)
}
}

object.forEach {
XCTFail("Extra key: \($0.key)", file: file, line: line)
}
} else {
XCTFail("Expected object `\(name)` in Node", file: file, line: line)
}
}
}

0 comments on commit cba7bae

Please sign in to comment.