Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda