Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test description in ForEachOnRangeSpec.kt #4402

Merged
merged 1 commit into from Dec 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,9 +7,11 @@ import org.spekframework.spek2.style.specification.describe

class ForEachOnRangeSpec : Spek({

val subject by memoized { ForEachOnRange() }

describe("ForEachOnRange rule") {

context("a kt file with using a forEach on a range") {
context("using a forEach on a range") {
val code = """
fun test() {
(1..10).forEach {
Expand All @@ -28,25 +30,25 @@ class ForEachOnRangeSpec : Spek({
"""

it("should report the forEach usage") {
val findings = ForEachOnRange().compileAndLint(code)
val findings = subject.compileAndLint(code)
assertThat(findings).hasSize(4)
}
}

context("a kt file with using any other method on a range") {
context("using any other method on a range") {
val code = """
fun test() {
(1..10).isEmpty()
}
"""

it("should report not report any issues") {
val findings = ForEachOnRange().compileAndLint(code)
it("should not report any issues") {
val findings = subject.compileAndLint(code)
assertThat(findings).isEmpty()
}
}

context("a kt file with using a forEach on a list") {
context("using a forEach on a list") {
val code = """
fun test() {
listOf(1, 2, 3).forEach {
Expand All @@ -55,8 +57,8 @@ class ForEachOnRangeSpec : Spek({
}
"""

it("should report not report any issues") {
val findings = ForEachOnRange().compileAndLint(code)
it("should not report any issues") {
val findings = subject.compileAndLint(code)
assertThat(findings).isEmpty()
}
}
Expand Down