-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP 318 Move Gradle plugin classes to sub package
- Loading branch information
Showing
8 changed files
with
114 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...-plugin/src/test/groovy/org/aim42/htmlsanitycheck/gradle/HtmlSanityCheckPluginSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.aim42.htmlsanitycheck.gradle | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.language.base.plugins.LifecycleBasePlugin | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
|
||
class HtmlSanityCheckPluginSpec extends Specification { | ||
|
||
def "plugin adds an htmlSanityCheck task to the project"() { | ||
given: "a project" | ||
Project project = ProjectBuilder.builder().build() | ||
|
||
when: "the plugin is applied" | ||
project.plugins.apply HtmlSanityCheckPlugin | ||
|
||
then: "the htmlSanityCheck task is added" | ||
project.tasks.named(HtmlSanityCheckPlugin.HTML_SANITY_CHECK) != null | ||
} | ||
|
||
def "htmlSanityCheck task has correct type and properties"() { | ||
given: "a project with the plugin applied" | ||
Project project = ProjectBuilder.builder().build() | ||
project.plugins.apply(HtmlSanityCheckPlugin) | ||
|
||
when: "retrieving the htmlSanityCheck task" | ||
def task = project.tasks.named(HtmlSanityCheckPlugin.HTML_SANITY_CHECK).get() | ||
|
||
then: "the task is of type HtmlSanityCheckTask" | ||
task instanceof HtmlSanityCheckTask | ||
|
||
and: "the task has the correct description" | ||
task.description == 'performs semantic checks on html files' | ||
|
||
and: "the task is in the verification group" | ||
task.group == LifecycleBasePlugin.VERIFICATION_GROUP | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../HtmlSanityCheckTaskFunctionalTest.groovy → .../HtmlSanityCheckTaskFunctionalTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...le-plugin/src/test/groovy/org/aim42/htmlsanitycheck/gradle/HtmlSanityCheckTaskSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.aim42.htmlsanitycheck.gradle | ||
|
||
import org.aim42.htmlsanitycheck.MisconfigurationException | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
|
||
class HtmlSanityCheckTaskSpec extends Specification { | ||
|
||
def "should initialize task with defaults"() { | ||
given: | ||
def project = ProjectBuilder.builder().build() | ||
def task = project.tasks.register('htmlSanityCheck', HtmlSanityCheckTask) | ||
|
||
expect: | ||
task.failOnErrors == false | ||
task.httpConnectionTimeout == 5000 | ||
task.ignoreLocalHost == false | ||
task.ignoreIPAddresses == false | ||
task.checkingResultsDir == new File(project.DEFAULT_BUILD_DIR_NAME, '/reports/htmlSanityCheck/') | ||
task.junitResultsDir == new File(project.DEFAULT_BUILD_DIR_NAME, '/test-results/htmlSanityCheck/') | ||
} | ||
|
||
def "should set source directory and files"() { | ||
given: | ||
def project = ProjectBuilder.builder().build() | ||
def task = project.tasks.register('htmlSanityCheck', HtmlSanityCheckTask.class) | ||
def sourceDir = new File(project.DEFAULT_BUILD_DIR_NAME, "/resources/test/resources") | ||
sourceDir.mkdirs() | ||
def testFile = new File(sourceDir, "file-to-test.html") | ||
testFile << """<html></html>""" | ||
|
||
when: | ||
task.sourceDir = sourceDir | ||
task.httpSuccessCodes = [299] | ||
task.httpErrorCodes = [599] | ||
task.httpWarningCodes = [199] | ||
task.sanityCheckHtml() | ||
|
||
then: | ||
task.sourceDocuments != null | ||
} | ||
|
||
def "should throw exception if configuration is invalid"() { | ||
given: | ||
def project = ProjectBuilder.builder().build() | ||
def task = project.tasks.register('htmlSanityCheck', HtmlSanityCheckTask.class) | ||
task.failOnErrors = true | ||
|
||
when: | ||
task.sanityCheckHtml() | ||
|
||
then: | ||
def e = thrown(MisconfigurationException) | ||
e.message.contains("source directory must not be null") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters