-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from grails/scaffolding
Update Scaffolding Feature
- Loading branch information
Showing
8 changed files
with
95 additions
and
6 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
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
29 changes: 29 additions & 0 deletions
29
grails-forge-core/src/test/groovy/org/grails/forge/feature/view/ScaffoldingSpec.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,29 @@ | ||
package org.grails.forge.feature.view | ||
|
||
import org.grails.forge.ApplicationContextSpec | ||
import org.grails.forge.BuildBuilder | ||
import org.grails.forge.feature.Features | ||
import org.grails.forge.fixture.CommandOutputFixture | ||
|
||
class ScaffoldingSpec extends ApplicationContextSpec implements CommandOutputFixture { | ||
|
||
void "test scaffolding feature"() { | ||
when: | ||
final Features features = getFeatures(['scaffolding']) | ||
|
||
then: | ||
features.contains('scaffolding') | ||
} | ||
|
||
void "test dependencies are present in build.gradle"() { | ||
when: | ||
final String template = new BuildBuilder(beanContext) | ||
.features(['scaffolding']) | ||
.render() | ||
|
||
then: | ||
template.contains('implementation("org.grails.plugins:scaffolding")') | ||
template.contains('runtimeOnly("org.fusesource.jansi:jansi:1.18")') | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
test-core/src/test/groovy/org/grails/forge/features/scaffolding/ScaffoldingSpec.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,40 @@ | ||
package org.grails.forge.features.scaffolding | ||
|
||
import org.gradle.testkit.runner.BuildResult | ||
import org.grails.forge.options.Language | ||
import org.grails.forge.utils.CommandSpec | ||
|
||
class ScaffoldingSpec extends CommandSpec { | ||
|
||
void "test generate-controller command"() { | ||
|
||
given: | ||
generateProject(Language.DEFAULT_OPTION) | ||
|
||
when: | ||
final File domainPkg = new File(dir, "grails-app/domain/example/grails") | ||
domainPkg.mkdirs() | ||
new File(domainPkg, "Bird.groovy").text = '''package example.grails | ||
class Bird { | ||
String name | ||
} | ||
''' | ||
final String output = executeGradle("runCommand", "-Pargs=generate-controller example.grails.Bird").getOutput() | ||
|
||
then: | ||
output.contains('Rendered template Controller.groovy to destination grails-app/controllers/example/grails/BirdController.groovy') | ||
output.contains('Rendered template Service.groovy to destination grails-app/services/example/grails/BirdService.groovy') | ||
output.contains('Rendered template Spec.groovy to destination src/test/groovy/example/grails/BirdControllerSpec.groovy') | ||
output.contains('Rendered template ServiceSpec.groovy to destination src/test/groovy/example/grails/BirdServiceSpec.groovy') | ||
new File(dir, "grails-app/controllers/example/grails/BirdController.groovy").exists() | ||
new File(dir, "grails-app/services/example/grails/BirdService.groovy").exists() | ||
new File(dir, "src/test/groovy/example/grails/BirdControllerSpec.groovy").exists() | ||
new File(dir, "src/test/groovy/example/grails/BirdControllerSpec.groovy").exists() | ||
} | ||
|
||
@Override | ||
String getTempDirectoryPrefix() { | ||
'testapp' | ||
} | ||
} |
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