add tags for rspec via system properties

This commit is contained in:
Christian Meier 2015-07-22 18:23:06 +02:00
parent 5ff567efb6
commit c11a198be4
3 changed files with 80 additions and 4 deletions

View File

@ -61,10 +61,17 @@ class RSpec extends DefaultTask {
if (pattern != null) {
args += ['--pattern', pattern]
}
String tags = System.getProperty("${name}.tags")
if (tags != null) {
tags.split(/\s+/).each { args += ['--tags', it] }
}
String file = System.getProperty("${name}.file")
if (file != null) {
args += [file]
}
jruby.exec(args)
}
}

View File

@ -286,4 +286,73 @@ class JRubyRSpecPluginSpec extends Specification {
then:
thrown(ExecException)
}
def "Run rspec with unknown tag"() {
given:
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
project.evaluate()
System.setProperty('rspec.tags', 'me_and_the_corner:today')
Task task = project.tasks.getByName('rspec')
String output = captureStdout {
task.run()
}
expect:
output.contains( '4 examples, 0 failures' )
}
def "Run rspec with simple tag"() {
given:
System.properties.remove('rspec.file')
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
project.evaluate()
System.setProperty('rspec.tags', 'simple')
Task task = project.tasks.getByName('rspec')
String output = captureStdout {
task.run()
}
expect:
output.contains( '1 example, 0 failures' )
}
def "Run rspec with name:value tags"() {
given:
System.properties.remove('rspec.file')
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
project.evaluate()
System.setProperty('rspec.tags', 'simple:false')
Task task = project.tasks.getByName('rspec')
String output = captureStdout {
task.run()
}
expect:
output.contains( '2 examples, 0 failures' )
}
def "Run rspec with multiple tags"() {
given:
System.properties.remove('rspec.file')
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
project.evaluate()
System.setProperty('rspec.tags', 'simple counter:small')
Task task = project.tasks.getByName('rspec')
String output = captureStdout {
task.run()
}
expect:
output.contains( '2 examples, 0 failures' )
}
def "Run rspec with skipping tag"() {
given:
System.properties.remove('rspec.file')
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
project.evaluate()
System.setProperty('rspec.tags', '~simple')
Task task = project.tasks.getByName('rspec')
String output = captureStdout {
task.run()
}
expect:
output.contains( '3 examples, 0 failures' )
}
}

View File

@ -1,17 +1,17 @@
describe 'Simple' do
it 'should' do
it 'should', :simple => true do
expect(true).to eq true
end
it 'has no $CLASSPATH entries' do
it 'has no $CLASSPATH entries', :counter => 'small' do
expect($CLASSPATH.size).to eq 0
end
it 'has some loaded gems' do
it 'has some loaded gems', :counter => 'big', :simple => false do
expect(Gem.loaded_specs.size).to eq 6
end
it 'has some loaded gems' do
it 'has some loaded gems', :simple => false do
require 'rspec'
expect(Gem.loaded_specs['rspec'].version.to_s).not_to eq '3.2.0'
end