Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1: support for dutch #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ out/
.settings/
.classpath
.project
.gradle
.gradle
.idea
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

buildscript {
repositories {
mavenCentral()
maven { url 'http://repo.springsource.org/plugins-release' }
mavenLocal()
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
classpath 'com.github.samueltbrown:gradle-cucumber-plugin:0.7'
classpath 'net.researchgate:gradle-release:2.0.2'
}
}

Expand All @@ -37,7 +39,9 @@ subprojects {
apply plugin: 'propdeps'

repositories {
mavenLocal()
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
}

sourceCompatibility = 1.6
Expand All @@ -50,9 +54,11 @@ allprojects {
apply plugin: 'eclipse'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
apply plugin: 'maven'
apply plugin: 'net.researchgate.release'

group = 'io.jdev.cucumber'
version = '0.5'
version = '0.6-SNAPSHOT'

ext {
cucumberJvmVersion = "1.1.8"
Expand Down Expand Up @@ -97,3 +103,4 @@ allprojects {
}
}
}

8 changes: 4 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ uploadArchives { task ->
uniqueVersion = false
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(task)) {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeOssUsername, password: sonatypeOssPassword)
repository(url: "http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/repositories/releases/") {
authentication(userName: "deployment", password: "h0o4c2h5d8")
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: sonatypeOssUsername, password: sonatypeOssPassword)
snapshotRepository(url: "http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/repositories/snapshots/") {
authentication(userName: "deployment", password: "h0o4c2h5d8")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions core/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.6-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 the original author or authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package io.jdev.cucumber.variables.groovy.nl
import cucumber.api.Scenario
import io.jdev.cucumber.variables.core.BasicSteps
import io.jdev.cucumber.variables.nl.DutchDecoder

import static cucumber.api.groovy.EN.Given
import static cucumber.api.groovy.Hooks.After
import static cucumber.api.groovy.Hooks.Before

def steps = new BasicSteps()

Before() { Scenario scenario ->
steps.before(scenario, new DutchDecoder())
}

After() { Scenario scenario ->
steps.after(scenario)
}

Given(~/^de (.*) is gevuld met (.*)$/) { String name, String value ->
steps.setVariable(name, steps.getVariable(value));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 the original author or authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package io.jdev.cucumber.variables.java.nl;

import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.nl.Gegeven;
import io.jdev.cucumber.variables.core.BasicSteps;
import io.jdev.cucumber.variables.nl.DutchDecoder;

public class BasicVariableStepsNL {

private BasicSteps steps = new BasicSteps();

@Before
public void before(Scenario scenario) {
steps.before(scenario, new DutchDecoder());
}

@After
public void after(Scenario scenario) {
steps.after(scenario);
}

@Gegeven("^de (.*) is gevuld met (.*)$")
public void set(String name, String value) {
steps.setVariable(name, steps.getVariable(value));
}

}
42 changes: 42 additions & 0 deletions core/src/main/java/io/jdev/cucumber/variables/nl/DutchDecoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 the original author or authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package io.jdev.cucumber.variables.nl;

import io.jdev.cucumber.variables.core.ChainedDecoder;
import io.jdev.cucumber.variables.core.RegexLiteralDecoder;
import io.jdev.cucumber.variables.core.RegexVariableDecoder;
import io.jdev.cucumber.variables.core.StringLiteralDecoder;

public class DutchDecoder extends ChainedDecoder {

public DutchDecoder() {
super(
new RegexVariableDecoder("de(?: (\\d+)(?:ste|de))? (.*)", 2, 1),
new StringLiteralDecoder(),
new RegexLiteralDecoder()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 the original author or authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package io.jdev.cucumber.variables.java.nl

import cucumber.api.Scenario
import io.jdev.cucumber.variables.VariableScope
import io.jdev.cucumber.variables.nl.DutchDecoder
import spock.lang.Specification

class BasicVariableStepsSpec extends Specification {

BasicVariableStepsNL steps
Scenario scenario
Scenario previousScenario

void setup() {
steps = new BasicVariableStepsNL()
scenario = Mock(Scenario)
previousScenario = Mock(Scenario)
}

void cleanup() {
VariableScope.removeCurrentScope()
}

void "before step should set up variable scope when none present"() {
given: 'no current scope attached to thread'
VariableScope.removeCurrentScope()

when: 'call before method'
steps.before(scenario)

then: 'scope created and attached to given scenario'
def scope = VariableScope.currentScope
scope != null
scope.scenario == scenario
}

void "before step should replace variable scope when one already present"() {
given: 'existing scope attached to thread'
def previousScope = VariableScope.getCurrentScope(previousScenario, new DutchDecoder())
previousScope.storeVariable("dog name", 'Mork')

when: 'call before method'
steps.before(scenario)

then: 'scope has replaced previous one on the thread'
def scope = VariableScope.currentScope
scope != null
scope.scenario == scenario

// ok it's more of an integration test
and: 'does not have previously set variable'
scope.decodeVariable('de dog name') == null

when: 'set a variable'
scope.storeVariable("dog name", 'Mindy')

then: 'decodes as expected'
scope.decodeVariable('de dog name') == 'Mindy'
scope.decodeVariable('de 1ste dog name') == 'Mindy'

and: 'previous scope unchanged'
previousScope.decodeVariable('de 1ste dog name') == 'Mork'
previousScope.decodeVariable('de dog name') == 'Mork'
}

void "set step should set variable"() {
given: 'current scope attached to thread'
steps.before(scenario)

when: 'call set method'
def val = 'blah'
steps.set('foo', "'$val'")

then: 'scope has given variable'
VariableScope.currentScope.decodeVariable('de foo') == val
}

}
Loading