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

Evaluate TodaysDate and expresions inside Preformatted blocks #1017

Merged
merged 7 commits into from Dec 22, 2018

Conversation

jaruzafa
Copy link
Contributor

Hi!
Please, take into consideration this pull request.
It enables the evaluation of TodaysDate and expressions inside Preformatted blocks.

Context:
Currently, preformated (blocks enclosed by {{{ foo }}} ) allow variables in them.
Example:

!define FOO {bar}
{{{
 Hi ${FOO} !
}}}

Will be rendered as:
Hi bar !

Just variables are evaluated, so this:
Example 2:

!define FOO {bar}
!define SUM {5+1}
{{{
 Hi ${FOO} !
 Today is !today
 ${=${SUM}=}
}}}

Will be rendered as:

 Hi bar !
 Today is !today
 Sum is ${=5+1=}

New behaviour
With my change, example 2 will be rendered as:

 Hi bar !
 Today is 1 Jan, 2017
 Sum is 6

This is useful for parametrizing tests. I use it in conjunction with hsac fixtures to parametrize XML requests and show them properly in a table.

Example:

!define REQ { {{{
<?xml version="1.0"?>
<GetSomething>
            <Pick>
                <Date>!today (yyyy-MM-dd) +1</Date>
                <Time>10:00</Time>
            </Pick>
            <Drop>
                <Date>!today (yyyy-MM-dd) +15</Date>
                <Time>10:00</Time>
            </Drop>
</GetSomething>
}}} }

|script  |xml http test                                                      |
|post    |${REQ}                  |to     |htttp://testsite.com    |
|check  |response status    |200                             |
|show   |response                                                  |
|check  |xPath                    |!-//result/text()-! |ok   |

Cheers!

@amolenaar
Copy link
Collaborator

This looks like a nice addition. Can you add an (acceptance) test? That way this behaviour will not change by accident.

@jaruzafa
Copy link
Contributor Author

jaruzafa commented Mar 6, 2018

Hi @amolenaar,
As requested, I added an acceptance test to my pull request.

Regards!

@fhoeben fhoeben merged commit a0833a4 into unclebob:master Dec 22, 2018
fhoeben added a commit that referenced this pull request Dec 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants