add file picker for rspec via system properties

-D{task.name}.file=... picks either a directory or a file which gets
executed with rspec
This commit is contained in:
Christian Meier 2015-07-20 21:41:40 +02:00
parent d0828867a7
commit c574684339
2 changed files with 48 additions and 0 deletions

View File

@ -61,6 +61,10 @@ class RSpec extends DefaultTask {
if (pattern != null) {
args += ['--pattern', pattern]
}
String file = System.getProperty("${name}.file")
if (file != null) {
args += [file]
}
jruby.exec(args)
}
}

View File

@ -242,4 +242,48 @@ class JRubyRSpecPluginSpec extends Specification {
output.contains( '0 examples, 0 failures' )
outputOther.contains( '4 examples, 0 failures' )
}
def "Run rspec with directory picker via system properties"() {
given:
Task task = project.tasks.create('other', RSpec)
project.evaluate()
System.setProperty('rspec.file', new File('src/test/resources/simple/spec').absolutePath)
String output = captureStdout {
project.tasks.getByName('rspec').run()
}
String outputOther = captureStdout {
task.run()
}
expect:
outputOther.contains( '0 examples, 0 failures' )
output.contains( '4 examples, 0 failures' )
}
def "Run rspec task with file picker via system properties"() {
given:
Task task = project.tasks.create('other', RSpec)
project.evaluate()
System.properties.remove('rspec.file')
System.setProperty('other.file', new File('src/test/resources/simple/spec/one_spec.rb').absolutePath)
String outputOther = captureStdout {
project.tasks.getByName('rspec').run()
}
String output = captureStdout {
task.run()
}
expect:
outputOther.contains( '0 examples, 0 failures' )
output.contains( '4 examples, 0 failures' )
}
def "fails rspec with file picker if file is missing"() {
when:
project.evaluate()
System.setProperty('rspec.file', 'path/does/not/exists/one_spec.rb')
String output = captureStdout {
project.tasks.getByName('rspec').run()
}
then:
thrown(ExecException)
}
}