cgiffard / Behaviour-Assertion-Sheets

CSS-like declarative DSL for web integration testing.
http://bas.cgiffard.com/
138 stars 8 forks source link

Allow for empty alt attribute #12

Closed Melindrea closed 11 years ago

Melindrea commented 11 years ago

Hello!

Very nice tool, and now I've gotten to start experimenting with it. I like the idea of using BAS to check that the site is accessible, but I'm having difficulties getting the assertions to work.

It is okay to have an image with an empty alt attribute (generally if the image is more for decoration than anything else), but running the test suite with either "required" or "true", I get "'attribute(alt)' expects true: Component test 'true' failed against input 'false'.", when the image in question has an empty alt attribute.

I am kind of guessing this is per your specification, but how do I get the requirement I need?

cgiffard commented 11 years ago

Hey! Sorry for taking so long to get back to you. :(

The way the required/true/exists bareword tests work at the moment is via JavaScript's own concept of truthiness - so an empty string is considered false even though it's a value according to HTML.

I'm not sure I want to change this (although I'd love to have a chat about it if you disagree with me!) because it could break peoples expectations for how these barewords should work when using them in other places.

Instead, how about I add you something similar to a 'has-attribute' test, which would return a true or false value if the attribute is present on a node, regardless of what it contains?

Melindrea commented 11 years ago

Has-attribute would fulfil my use-case splendidly! Nice work with the project.

Christopher Giffard notifications@github.com skrev:

Hey! Sorry for taking so long to get back to you. :(

The way the required/true/exists bareword tests work at the moment is via JavaScript's own concept of truthiness - so an empty string is considered false even though it's a value according to HTML.

I'm not sure I want to change this (although I'd love to have a chat about it if you disagree with me!) because it could break peoples expectations for how these barewords should work when using them in other places.

Instead, how about I add you something similar to a 'has-attribute' test, which would return a true or false value if the attribute is present on a node, regardless of what it contains?


Reply to this email directly or view it on GitHub: https://github.com/cgiffard/Behaviour-Assertion-Sheets/issues/12#issuecomment-17978965

Skickat från min Android-telefon med K-9 E-post. Ursäkta min fåordighet.

cgiffard commented 11 years ago

Hey again! :)

I've added the has-attribute test, and some tests for it (describing Bas' own test suite always gets so meta, haha!)

Let me know how it goes for you!

Christopher

cgiffard commented 11 years ago

(Oh, if you're installing from npm, the version you want is 0.0.13.)

Melindrea commented 11 years ago

You rock, that works perfectly!

cgiffard commented 11 years ago

No worries, glad it all worked out!