added configuration property 'pattern'

which corresponds to the rspec options --pattern
This commit is contained in:
Christian Meier 2015-07-20 17:46:26 +02:00
parent 23ebd858cb
commit 99a6852a07
3 changed files with 35 additions and 3 deletions

View File

@ -39,7 +39,7 @@ public class JRubyUtils {
GemUtils.setupJars(config, gemDir, GemUtils.OverwriteAction.OVERWRITE)
}
public void exec(String... arguments) {
public void exec(List<String> arguments) {
project.javaexec {
classpath jrubyCompleteJar.absolutePath
// JRuby looks on the classpath inside the 'bin' directory

View File

@ -22,6 +22,9 @@ class RSpec extends DefaultTask {
@Input
String version = DEFAULT_VERSION
@Input
String pattern
@Input
String jrubyVersion = project.jruby.defaultVersion
@ -29,6 +32,10 @@ class RSpec extends DefaultTask {
this.version = version
}
void pattern(String files) {
this.pattern = files
}
void jrubyVersion(String version) {
this.jrubyVersion = version
}
@ -50,6 +57,10 @@ class RSpec extends DefaultTask {
jruby.setupGemsAndJars()
jruby.exec('-S', 'rspec')
List<String> args = ['-S', 'rspec']
if (pattern != null) {
args += ['--pattern', pattern]
}
jruby.exec(args)
}
}

View File

@ -198,7 +198,7 @@ class JRubyRSpecPluginSpec extends Specification {
task.run()
}
expect:
output.contains( '2 examples, 0 failures' )
output.contains( '1 example, 0 failures' )
}
def "Run custom rspec version separate from other tasks"() {
@ -221,4 +221,25 @@ class JRubyRSpecPluginSpec extends Specification {
outputOther.contains( '1 example, 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' )
}
}