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

@As drops last character in particular case #118

Closed
nikowitt opened this issue Sep 11, 2015 · 5 comments
Closed

@As drops last character in particular case #118

nikowitt opened this issue Sep 11, 2015 · 5 comments
Assignees
Milestone

Comments

@nikowitt
Copy link
Contributor

Hi Jan,

some small thing I've just observed:

    @As("$ entity [with restrictions $]")
    public T entity_of_$_with_restrictions_$(@SimpleClassName Class<? extends Base<?>> clazz,
            Criterion... restrictions)
            throws Exception {
(...)
    }

which is called via

.entity_of_$_with_restrictions_$(MetaDocument.class, Restrictions.isEmpty(MetaDocument.TRANSMITTALS),
                        Restrictions.gt(Base.NUMBER_OF_ATTACHMENTS, 0))

results in the report

     And metadocument entity [with restrictions transmittals is empty, numberOfAttachments>0

The last "]" is dropped. When I'm using

    @As("$ entity [with restrictions $ ]")

with a blank after $, the report is printed out correctly:

     And metadocument entity [with restrictions transmittals is empty, numberOfAttachments>0 ]

Best regards,
Niko

@janschaefer
Copy link
Contributor

Ok. This is actually a 'feature' of JGiven. This allows you to give the placeholders names. So when you can write @as("$entity entity") and the whole word $entity will be replaced by the placeholder. In this case, JGiven treats $] as the placeholder to replace.

@janschaefer
Copy link
Contributor

I think I could change the behavior here to only allow [a-zA-Z0-9] as valid characters for a placeholder name. This would also be consistent with what is allowed for normal Java methods.

@janschaefer janschaefer added this to the 0.8.2 milestone Sep 11, 2015
@janschaefer janschaefer self-assigned this Sep 11, 2015
@janschaefer
Copy link
Contributor

I think it is also fair to treat this as a bug ;-)

@nikowitt
Copy link
Contributor Author

Either that or a minimum length of at least 2 characters is required, but maybe it makes sense to define a single char name like $a, so your suggestion is probably the best solution.

@janschaefer janschaefer modified the milestones: 0.9.0, 0.8.2 Sep 12, 2015
@janschaefer
Copy link
Contributor

I actually decided to rewrite most of the placeholder parsing, which introduces a small backwards incompatibility. Thus this fix will be released with 0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants