Testing (test device) - the name and content of the meta tag to ensure that the content is not empty

It is very difficult for me to figure out how to make sure that the meta-header content attribute is not empty using either assert_select or assert_tag. I can’t figure out how to make it work together.

To give you a better idea, here is an example of how I want the test to work:

This should go through:

[meta name = "title" content = "Hello" /]

This should fail:

[meta name = "title" content = "" /]

[note: the absence of a tag should not work at all]

+4
source share
1 answer

I got it to work shortly after posting with a little help from the IRC and sample documentation as a base. Instead of deleting the message, I will support it because it was surprisingly annoying to keep track of.

Here is the code:

assert_select "meta[name=title]" do assert_select "[content=?]", /.+/ end 
+5
source

Source: https://habr.com/ru/post/1502196/


All Articles