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

Makes it possible to add extra spaces between the Action and the text… #1734

Merged
merged 4 commits into from
Aug 21, 2021
Merged
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
26 changes: 13 additions & 13 deletions karate-core/src/main/java/com/intuit/karate/ScenarioActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void configureDocString(String key, String exp) {
}

@Override
@When("^configure ([^\\s]+) = (.+)")
@When("^configure\\h+([^\\s]+)\\h+= (.+)")
public void configure(String key, String exp) {
engine.configure(key, exp);
}
Expand All @@ -83,7 +83,7 @@ public void path(String exp) {
}

@Override
@When("^param ([^\\s]+) = (.+)")
@When("^param\\h+([^\\s]+)\\h+= (.+)")
public void param(String name, String exp) {
engine.param(name, exp);
}
Expand All @@ -95,7 +95,7 @@ public void params(String exp) {
}

@Override
@When("^cookie ([^\\s]+) = (.+)")
@When("^cookie\\h+([^\\s]+)\\h+= (.+)")
public void cookie(String name, String value) {
engine.cookie(name, value);
}
Expand All @@ -119,7 +119,7 @@ public void csvDocString(String name, String exp) {
}

@Override
@When("^header ([^\\s]+) = (.+)")
@When("^header\\h+([^\\s]+)\\h+= (.+)")
public void header(String name, String exp) {
engine.header(name, exp);
}
Expand All @@ -131,7 +131,7 @@ public void headers(String exp) {
}

@Override
@When("^form field ([^\\s]+) = (.+)")
@When("^form field\\h+([^\\s]+)\\h+= (.+)")
public void formField(String name, String exp) {
engine.formField(name, exp);
}
Expand Down Expand Up @@ -177,13 +177,13 @@ public void replace(String name, List<Map<String, String>> table) {
}

@Override
@When("^replace (\\w+).([^\\s]+) = (.+)")
@When("^replace\\h+(\\w+).([^\\s]+)\\h+= (.+)")
public void replace(String name, String token, String value) {
engine.replace(name, token, value);
}

@Override
@When("^def (\\w+) = (.+)")
@When("^def \\h*(\\w+)\\h+=\\h+(.+)")
public void def(String name, String exp) {
engine.assign(AssignType.AUTO, name, exp, false);
}
Expand All @@ -192,7 +192,7 @@ public void def(String name, String exp) {
@When("^def (.+) =$")
public void defDocString(String name, String exp) {
engine.assign(AssignType.AUTO, name, exp, false); // auto-parse json and xml
}
}

@Override
@When("^text (.+) =$")
Expand Down Expand Up @@ -255,7 +255,7 @@ public void assertTrue(String exp) {
}

@Override
@When("^method (\\w+)")
@When("^method\\h+(\\w+)")
public void method(String method) {
engine.method(method);
}
Expand Down Expand Up @@ -309,7 +309,7 @@ public void print(String exp) {
}

@Override
@When("^status (\\d+)")
@When("^status \\h*(\\d+)")
public void status(int status) {
engine.status(status);
}
Expand All @@ -330,13 +330,13 @@ public void match(String exp, String op1, String op2, String rhs) {
}

@Override
@When("^set ([^\\s]+)( .+)? =$")
@When("^set\\h+([^\\s]+)( .+)? =$")
public void setDocString(String name, String path, String value) {
engine.set(name, path, value);
}

@Override
@When("^set ([^\\s]+)( .+)? = (.+)")
@When("^set\\h+([^\\s]+)( .+)?\\h+= (.+)")
public void set(String name, String path, String value) {
engine.set(name, path, value);
}
Expand All @@ -353,7 +353,7 @@ public void set(String name, String path, List<Map<String, String>> table) {
}

@Override
@When("^remove ([^\\s]+)( .+)?")
@When("^remove\\h+([^\\s]+)( .+)?")
public void remove(String name, String path) {
engine.remove(name, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ void testAbort() {
match(fr.result.getVariables(), "{ configSource: 'normal', functionFromKarateBase: '#notnull', before: true }");
}

@Test
void testAlign() {
run("align.feature");
System.out.println(fr.result.getVariables());
match(fr.result.getVariables(), "{ configSource: 'normal', functionFromKarateBase: '#notnull', text: 'hello bar world' , cats: '#notnull', myJson: {}}}");
}

@Test
void testFailApi() {
fail = true;
Expand Down
24 changes: 24 additions & 0 deletions karate-core/src/test/java/com/intuit/karate/core/align.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature:

Scenario:
* assert 'red ' + 5 == 'red 5'
* table cats
| name | age |
| 'Bob' | 2 |
* match cats == [{name: 'Bob', age: 2}]

* def text = 'hello <foo> world'
* replace text.foo = 'bar'
* match text == 'hello bar world'
* print text

* def myJson = { foo: 'bar' }
* set myJson.foo = 'world'
* match myJson == { foo: 'world' }
* remove myJson.foo

* configure logPrettyResponse = true
* param myParam = 'foo'
* header transaction-id = 'test'
* cookie cook = 'bar'
* form field username = 'john'