add version configuration for each rspec task

This commit is contained in:
Christian Meier 2015-07-19 14:51:39 +02:00
parent de8f91d7b3
commit 1a9e0d381c
4 changed files with 55 additions and 0 deletions

View File

@ -19,11 +19,16 @@ class RSpec extends DefaultTask {
static final String DEFAULT_VERSION = '3.3.0'
@Input
String version = DEFAULT_VERSION
@Input
String jrubyVersion = project.jruby.defaultVersion
void version(String version) {
this.version = version
}
void jrubyVersion(String version) {
this.jrubyVersion = version
}

View File

@ -186,4 +186,43 @@ class JRubyRSpecPluginSpec extends Specification {
expect:
output.contains( '2 examples, 0 failures' )
}
def "Run custom rspec version"() {
given:
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/rspec-version/spec').getAbsoluteFile().toPath())
Task task = project.tasks.getByName('rspec')
task.configure {
version = '3.2.0'
}
project.evaluate()
String output = captureStdout {
task.run()
}
println output
expect:
output.contains( '1 example, 0 failures' )
}
def "Run custom rspec version separate from other tasks"() {
given:
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/rspec-version/spec').getAbsoluteFile().toPath())
Task task = project.tasks.create('other', RSpec)
task.configure {
version = '3.2.0'
}
project.evaluate()
String outputOther = captureStdout {
task.run()
}
println outputOther
specDir.delete()
Files.createSymbolicLink(specDir.toPath(), new File('src/test/resources/simple/spec').getAbsoluteFile().toPath())
String output = captureStdout {
project.tasks.getByName('rspec').run()
}
println output
expect:
outputOther.contains( '1 example, 0 failures' )
output.contains( '4 examples, 0 failures' )
}
}

View File

@ -0,0 +1,6 @@
describe 'RSpecVersion' do
it 'uses the right rspec version' do
require 'rspec'
expect(Gem.loaded_specs['rspec'].version.to_s).to eq '3.2.0'
end
end

View File

@ -10,4 +10,9 @@ describe 'Simple' do
it 'has some loaded gems' do
expect(Gem.loaded_specs.size).to eq 6
end
it 'has some loaded gems' do
require 'rspec'
expect(Gem.loaded_specs['rspec'].version.to_s).not_to eq '3.2.0'
end
end