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

Passing metadata to site generator #6

Open
joelmukuthu opened this issue Nov 20, 2016 · 3 comments
Open

Passing metadata to site generator #6

joelmukuthu opened this issue Nov 20, 2016 · 3 comments

Comments

@joelmukuthu
Copy link
Member

For assertions with alternations, in order for the site generator to be able to pick up the correct declaration rule you have to name the markdown file in your plugin with at least one alternation .

So for example to-be-the-start-of, the declaration rule for that assertion was not picked up. Under the title "to be the start of", there's supposed to be this declaration rule <moment> [not] to be the start of (second|minute|hour|day|week|isoWeek|month|quarter|year). In contrast, in to be truthy, the declaration rule was picked up correctly since the markdown file is named to-be-truthy.md.

I could fix the problem in my plugin by renaming my markdown file from to-be-the-start-of.md to to-be-the-start-of-second.md but then I'd have to create a copy of that file for every other alternation which would be too verbose in the docs (there's also to be the end of with just as many alternations). Or just create a single file to-be-the-start-of-second.md which I find might be a bit confusing to users.

So my ideal solution would be to put some code block or something in the markdown to tell the site generator which declaration rule to use for my assertion.

FYI, the failure is coming from this line. expect.assertions contains stuff like:

[
  'to be the start of second': { ... },
  'to be the start of minute': { ... },
  'to be the start of hour': { ... }
  ... and so on
]

while name is 'to be the start of'.

// cc @sunesimonsen

@sunesimonsen
Copy link
Member

That sounds like a bug, I'll take a look at it. Thanks for reporting it.
On Sun, 20 Nov 2016 at 11.12, Joel Mukuthu [email protected] wrote:

For assertions with alternations, in order for the site generator to be
able to pick up the correct declaration rule you have to name the markdown
file in your plugin with at least one alternation .

So for example to-be-the-start-of
http://unexpected.js.org/unexpected-moment/assertions/moment/to-be-the-start-of/,
the declaration rule for that assertion was not picked up. Under the title
"to be the start of", there's supposed to be this declaration rule
[not] to be the start of
(second|minute|hour|day|week|isoWeek|month|quarter|year). In contrast, in to
be truthy http://unexpected.js.org/assertions/any/to-be-truthy/, the
declaration rule was picked up correctly since the markdown file is named
to-be-truthy.md
https://github.com/unexpectedjs/unexpected/blob/92cc2751b5a0ffb38a91b7466b4553f0bb32a3cd/documentation/assertions/any/to-be-truthy.md
.

I could fix the problem in my plugin by renaming my markdown file from
to-be-the-start-of.md to to-be-the-start-of-second.md but then I'd have
to create a copy of that file for every other alternation which would be
too verbose in the docs (there's also to be the end of with just as many
alternations). Or just create a single file to-be-the-start-of-second.md
which I find might be a bit confusing to users.

So my ideal solution would be to put some code block or something in the
markdown to tell the site generator which declaration rule to use for my
assertion.

FYI, the failure is coming from this line

files[file].declarations = _.unique((expect.assertions[name] || []).filter(function (assertionRule) {
.
expect.assertions contains stuff like:

[
'to be the start of second': { ... },
'to be the start of minute': { ... },
'to be the start of hour': { ... }
... and so on
]

while name is 'to be the start of'.

// cc @sunesimonsen https://github.com/sunesimonsen


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFisodkOYOb2OfBjWQzeyL5_a6YX770ks5rAB0BgaJpZM4K3gCm
.

@sunesimonsen
Copy link
Member

Right that is actually not a bug - it only consider strings that are actually a valid assertion expansion. We could allow you to state the assertion to look for in the meta data, that would be nice.

@joelmukuthu
Copy link
Member Author

Yeah :)

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

No branches or pull requests

2 participants