Prevent JRubyStormLocal task from erroneously using the jrubyExec configuration
Fixes #12
This commit is contained in:
parent
90c92d045d
commit
a0b287c92a
|
@ -1,5 +1,6 @@
|
|||
package com.github.jrubygradle.storm
|
||||
|
||||
import com.github.jrubygradle.internal.JRubyExecUtils
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
|
||||
|
@ -10,9 +11,20 @@ import com.github.jrubygradle.internal.JRubyExecTraits
|
|||
* a given codebase
|
||||
*/
|
||||
class JRubyStormLocal extends JavaExec implements JRubyExecTraits {
|
||||
static final String DEFAULT_JRUBYSTORMLOCAL_CONFIG = 'jrubyStormLocal'
|
||||
/** parent from which this task will inherit some configuration */
|
||||
JRubyStorm parentTask
|
||||
|
||||
@Input
|
||||
@Override
|
||||
String getConfiguration() {
|
||||
/* Prevent the usage of jrubyExec as our configuration which is never correct */
|
||||
if (JRubyExecTraits.super.getConfiguration() == JRubyExecUtils.DEFAULT_JRUBYEXEC_CONFIG) {
|
||||
return DEFAULT_JRUBYSTORMLOCAL_CONFIG
|
||||
}
|
||||
return JRubyExecTraits.super.getConfiguration()
|
||||
}
|
||||
|
||||
/** Set a custom path (relative or absolute) to the file defining a Redstorm topology
|
||||
*
|
||||
* If this is not set, the parentTask's topology will be used
|
||||
|
|
|
@ -10,26 +10,24 @@ import org.gradle.testfixtures.ProjectBuilder
|
|||
*
|
||||
*/
|
||||
class JRubyStormLocalSpec extends Specification {
|
||||
protected Project project
|
||||
Project project
|
||||
JRubyStormLocal task
|
||||
|
||||
void setup() {
|
||||
project = ProjectBuilder.builder().build()
|
||||
project.apply plugin: 'com.github.jruby-gradle.storm'
|
||||
task = project.task('spock', type: JRubyStormLocal)
|
||||
}
|
||||
|
||||
def "jrubyStormLocal task should be a proper instance"() {
|
||||
when:
|
||||
project.task('jrubyStormLocal', type: JRubyStormLocal)
|
||||
|
||||
then:
|
||||
project.tasks.jrubyStormLocal instanceof JRubyStormLocal
|
||||
expect:
|
||||
task instanceof JRubyStormLocal
|
||||
}
|
||||
|
||||
def "the task should inherit the topology configured on the parent"() {
|
||||
given:
|
||||
JRubyStorm parent = project.task('spock-parent', type: JRubyStorm)
|
||||
parent.topology = 'foo.rb'
|
||||
JRubyStormLocal task = project.task('spock', type: JRubyStormLocal)
|
||||
|
||||
when:
|
||||
task.parentTask = parent
|
||||
|
@ -40,7 +38,6 @@ class JRubyStormLocalSpec extends Specification {
|
|||
|
||||
def "I should be able to set a topology to run without a parent task"() {
|
||||
given:
|
||||
JRubyStormLocal task = project.task('spock', type: JRubyStormLocal)
|
||||
String topologyFile = 'topology.rb'
|
||||
|
||||
when:
|
||||
|
@ -49,4 +46,21 @@ class JRubyStormLocalSpec extends Specification {
|
|||
then:
|
||||
task.topology == topologyFile
|
||||
}
|
||||
|
||||
@Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/12')
|
||||
def "default configuration should not be from JRubyExec"() {
|
||||
expect:
|
||||
task.configuration == JRubyStormLocal.DEFAULT_JRUBYSTORMLOCAL_CONFIG
|
||||
}
|
||||
|
||||
def "setting the configuration should work"() {
|
||||
given:
|
||||
final String configName = 'someConfiguration'
|
||||
|
||||
when:
|
||||
task.configuration configName
|
||||
|
||||
then:
|
||||
task.configuration == configName
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue