Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
RSpec expect is failing while comparing equal strings

I tried to update this test but it is failing to compare identical strings, even though I copied and pasted the "got" output back into the test case. Why is this RSpec test failing?

 Failure/Error: expect(first_item_cost).to eq("12 x $499 = $5,988")

   expected: "12 x $499 = $5,988"
        got: "12 x $499 = $5,988"

   (compared using ==)

Code:

first_item_cost = find('.cart-item-cost', match: :first).text
expect(first_item_cost).to eq("12 x $499 = $5,988")

RSpec 3.9

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I checked the encoding and bytes and discovered:

puts "Encoding: " + first_item_cost.encoding.to_s
puts "Bytes: " + first_item_cost.bytes.to_s

Output:

Encoding: UTF-8
Bytes: [49, 50, 32, 195, 151, 32, 36, 52, 57, 57, 32, 61, 32, 36, 53, 44, 57, 56, 56]

The 'x' has too many bytes! I looked in the template and sure enough it used ×. When I copied and pasted from the console, it must have lost the original character (or RSpec translated it before output). I changed the spec and template to x.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!