Merge pull request #2 from jruby-gradle/rspec
adds files configuration to rspec plugin
This commit is contained in:
commit
d0828867a7
|
@ -39,7 +39,7 @@ public class JRubyUtils {
|
||||||
GemUtils.setupJars(config, gemDir, GemUtils.OverwriteAction.OVERWRITE)
|
GemUtils.setupJars(config, gemDir, GemUtils.OverwriteAction.OVERWRITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exec(String... arguments) {
|
public void exec(List<String> arguments) {
|
||||||
project.javaexec {
|
project.javaexec {
|
||||||
classpath jrubyCompleteJar.absolutePath
|
classpath jrubyCompleteJar.absolutePath
|
||||||
// JRuby looks on the classpath inside the 'bin' directory
|
// JRuby looks on the classpath inside the 'bin' directory
|
||||||
|
|
|
@ -22,6 +22,9 @@ class RSpec extends DefaultTask {
|
||||||
@Input
|
@Input
|
||||||
String version = DEFAULT_VERSION
|
String version = DEFAULT_VERSION
|
||||||
|
|
||||||
|
@Input
|
||||||
|
String pattern
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
String jrubyVersion = project.jruby.defaultVersion
|
String jrubyVersion = project.jruby.defaultVersion
|
||||||
|
|
||||||
|
@ -29,6 +32,10 @@ class RSpec extends DefaultTask {
|
||||||
this.version = version
|
this.version = version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pattern(String files) {
|
||||||
|
this.pattern = files
|
||||||
|
}
|
||||||
|
|
||||||
void jrubyVersion(String version) {
|
void jrubyVersion(String version) {
|
||||||
this.jrubyVersion = version
|
this.jrubyVersion = version
|
||||||
}
|
}
|
||||||
|
@ -50,6 +57,10 @@ class RSpec extends DefaultTask {
|
||||||
|
|
||||||
jruby.setupGemsAndJars()
|
jruby.setupGemsAndJars()
|
||||||
|
|
||||||
jruby.exec('-S', 'rspec')
|
List<String> args = ['-S', 'rspec']
|
||||||
|
if (pattern != null) {
|
||||||
|
args += ['--pattern', pattern]
|
||||||
|
}
|
||||||
|
jruby.exec(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package com.github.jrubygradle.rspec
|
package com.github.jrubygradle.rspec
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
import org.gradle.api.InvalidUserDataException
|
import org.gradle.api.InvalidUserDataException
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.testfixtures.ProjectBuilder
|
|
||||||
import spock.lang.Specification
|
|
||||||
import org.gradle.process.internal.ExecException
|
import org.gradle.process.internal.ExecException
|
||||||
|
import org.gradle.testfixtures.ProjectBuilder
|
||||||
|
|
||||||
import java.nio.file.Files
|
import org.apache.tools.ant.util.TeeOutputStream
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Meier
|
* @author Christian Meier
|
||||||
|
@ -21,11 +24,11 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
def project
|
def project
|
||||||
def specDir
|
def specDir
|
||||||
|
|
||||||
static String captureStdout( Closure closure ){
|
static String captureStdout(Closure closure) {
|
||||||
OutputStream output = new ByteArrayOutputStream()
|
OutputStream output = new ByteArrayOutputStream()
|
||||||
PrintStream out = System.out
|
PrintStream out = System.out
|
||||||
try {
|
try {
|
||||||
System.out = new PrintStream(output)
|
System.out = new PrintStream(new TeeOutputStream(System.out, output))
|
||||||
closure.call()
|
closure.call()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -65,7 +68,7 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
if(TESTROOT.exists()) {
|
if(TESTROOT.exists()) {
|
||||||
// TESTROOT.deleteDir()
|
TESTROOT.deleteDir()
|
||||||
}
|
}
|
||||||
TESTROOT.mkdirs()
|
TESTROOT.mkdirs()
|
||||||
|
|
||||||
|
@ -136,9 +139,8 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
String output = captureStdout {
|
String output = captureStdout {
|
||||||
task.run()
|
task.run()
|
||||||
}
|
}
|
||||||
println output
|
|
||||||
expect:
|
expect:
|
||||||
output.contains( '3 examples, 0 failures' )
|
output.contains( '4 examples, 0 failures' )
|
||||||
}
|
}
|
||||||
|
|
||||||
def "Run rspec tasks separated"() {
|
def "Run rspec tasks separated"() {
|
||||||
|
@ -153,16 +155,14 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
String outputMine = captureStdout {
|
String outputMine = captureStdout {
|
||||||
task.run()
|
task.run()
|
||||||
}
|
}
|
||||||
println outputMine
|
|
||||||
|
|
||||||
specDir.delete()
|
specDir.delete()
|
||||||
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/more/spec').getAbsoluteFile().toPath())
|
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/more/spec').getAbsoluteFile().toPath())
|
||||||
String output = captureStdout {
|
String output = captureStdout {
|
||||||
project.tasks.getByName('rspec').run()
|
project.tasks.getByName('rspec').run()
|
||||||
}
|
}
|
||||||
println output
|
|
||||||
expect:
|
expect:
|
||||||
outputMine.contains( '3 examples, 0 failures' )
|
outputMine.contains( '4 examples, 0 failures' )
|
||||||
output.contains( '2 examples, 0 failures' )
|
output.contains( '2 examples, 0 failures' )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,6 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
String output = captureStdout {
|
String output = captureStdout {
|
||||||
task.run()
|
task.run()
|
||||||
}
|
}
|
||||||
println output
|
|
||||||
expect:
|
expect:
|
||||||
output.contains( '2 examples, 0 failures' )
|
output.contains( '2 examples, 0 failures' )
|
||||||
}
|
}
|
||||||
|
@ -198,7 +197,6 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
String output = captureStdout {
|
String output = captureStdout {
|
||||||
task.run()
|
task.run()
|
||||||
}
|
}
|
||||||
println output
|
|
||||||
expect:
|
expect:
|
||||||
output.contains( '1 example, 0 failures' )
|
output.contains( '1 example, 0 failures' )
|
||||||
}
|
}
|
||||||
|
@ -214,15 +212,34 @@ class JRubyRSpecPluginSpec extends Specification {
|
||||||
String outputOther = captureStdout {
|
String outputOther = captureStdout {
|
||||||
task.run()
|
task.run()
|
||||||
}
|
}
|
||||||
println outputOther
|
|
||||||
specDir.delete()
|
specDir.delete()
|
||||||
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
|
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
|
||||||
String output = captureStdout {
|
String output = captureStdout {
|
||||||
project.tasks.getByName('rspec').run()
|
project.tasks.getByName('rspec').run()
|
||||||
}
|
}
|
||||||
println output
|
|
||||||
expect:
|
expect:
|
||||||
outputOther.contains( '1 example, 0 failures' )
|
outputOther.contains( '1 example, 0 failures' )
|
||||||
output.contains( '4 examples, 0 failures' )
|
output.contains( '4 examples, 0 failures' )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "Run rspec with custom pattern"() {
|
||||||
|
given:
|
||||||
|
File specsDir = new File(project.projectDir, 'myspec').getAbsoluteFile()
|
||||||
|
Files.createSymbolicLink(specsDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
|
||||||
|
Task task = project.tasks.create('other', RSpec)
|
||||||
|
task.configure {
|
||||||
|
pattern 'myspec/*_spec.rb'
|
||||||
|
}
|
||||||
|
project.evaluate()
|
||||||
|
String outputOther = captureStdout {
|
||||||
|
task.run()
|
||||||
|
}
|
||||||
|
specsDir.delete()
|
||||||
|
String output = captureStdout {
|
||||||
|
project.tasks.getByName('rspec').run()
|
||||||
|
}
|
||||||
|
expect:
|
||||||
|
output.contains( '0 examples, 0 failures' )
|
||||||
|
outputOther.contains( '4 examples, 0 failures' )
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue