mike
mike

Reputation: 77

Verify text that has symbols

I need to verify text shows up on a webpage. Some of the text has symbols.

What is the best way to validate that the following appears on my page

"Test® Software for the low price of 7.451¢ per install"

I've looked at trying to escape the symbols but Im getting the following errors

 test.rb:61: invalid multibyte char (US-ASCII)
 test.rb:61: unterminated string meets end of file
 test.rb:61: syntax error, unexpected $end, expecting keyword_then or ';' or '\n'

Upvotes: 0

Views: 140

Answers (2)

Andrew Marshall
Andrew Marshall

Reputation: 96934

You need to put

# encoding: UTF-8

at the top of the test file containing the unicode characters. This is known as a "magic comment". You can and should read more about encoding in Ruby 1.9.

Upvotes: 2

wpgreenway
wpgreenway

Reputation: 1719

It sounds like you want to use HTML entities instead of symbols for display. If you do that, you can check for those entities in your test without these problems. So the HTML becomes:

"Test® Software for the low price of 7.451¢ per install"

Upvotes: 0

Related Questions