Files
SwiftLint/Tests/SwiftLintFrameworkTests/PrefixedTopLevelConstantRuleTests.swift
T
Keith Smiley 6eedf5d73c Add private_only to prefixed_toplevel_constant (#2315)
* Add private_only to prefixed_toplevel_constant

This allows users to opt in to only validate top level constants have
the given prefix if the constant is private or fileprivate.
2018-07-24 12:38:01 -07:00

27 lines
806 B
Swift

@testable import SwiftLintFramework
import XCTest
final class PrefixedTopLevelConstantRuleTests: XCTestCase {
func testDefaultConfiguration() {
verifyRule(PrefixedTopLevelConstantRule.description)
}
func testPrivateOnly() {
let triggeringExamples = [
"private let ↓Foo = 20.0",
"fileprivate let ↓foo = 20.0"
]
let nonTriggeringExamples = [
"let Foo = 20.0",
"internal let Foo = \"Foo\"",
"public let Foo = 20.0"
]
let description = PrefixedTopLevelConstantRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
verifyRule(description, ruleConfiguration: ["only_private": true])
}
}