[ 
https://jira.codehaus.org/browse/JBEHAVE-709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=289621#comment-289621
 ] 

Rui Figueira commented on JBEHAVE-709:
--------------------------------------

A patch for this issue is available at 
[https://github.com/ruifigueira/jbehave-core/commit/2b69281edf2aae7d34e4b262c49ca88625b2b999]
                
> Named parameters sorrounded by quotes are not handled properly
> --------------------------------------------------------------
>
>                 Key: JBEHAVE-709
>                 URL: https://jira.codehaus.org/browse/JBEHAVE-709
>             Project: JBehave
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 3.5.4
>            Reporter: Rui Figueira
>
> Wnen using jbehave with named parameters, order is not respected in parameter 
> injection if the named parameters are sorrounded with non-white characters 
> (for example, quotes).
> Here is a simple test:
> {code}
> public class QuoteNamedParametersStory extends JUnitStory {
>   public static class QuotNamedParametersSteps {
>     @Then("\"$foo\" then \"$bar\"")
>     public void otherOrderQuotes(@Named("bar") String bar, @Named("foo") 
> String foo) {
>       assertThat(foo, equalTo("foo"));
>       assertThat(bar, equalTo("bar"));
>     }
>   }
>   @Override
>   public Configuration configuration() {
>     return new MostUsefulConfiguration().useStoryReporterBuilder(new 
> StoryReporterBuilder().withFormats(Format.CONSOLE).withFailureTrace(true));
>   }
>   @Override
>   public List<CandidateSteps> candidateSteps() {
>     return new InstanceStepsFactory(configuration(), new 
> QuotNamedParametersSteps()).createCandidateSteps();
>   }
> }
> {code}
> And the corresponding quote_named_parameters_story.story:
> {noformat}
> Scenario: quotes on named parameters are problematic...
> Then "foo" then "bar"
> {noformat}
> I was able to fix it (and pass the above test successfully) by changing 
> {{org.jbehave.core.parsers.RegexPrefixCapturingPatternParser.Parameter}} to:
> {code}
> private class Parameter {
>   private final int start;
>   private final int end;
>   private final String whitespaceIfAny;
>   private final String name;
>   public Parameter(String pattern, int start, int end,
>       String whitespaceIfAny) {
>     this.start = start;
>     this.end = end;
>     this.whitespaceIfAny = whitespaceIfAny;
>     this.name = pattern.substring(start + prefix.length(), end - 
> whitespaceIfAny.length()).trim();
>   }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to