kucaahbe / rspec-html-matchers

Old school have_tag, with_tag(and more) matchers for rspec 3 (Nokogiri powered)
http://rubygems.org/gems/rspec-html-matchers
MIT License
199 stars 90 forks source link

Unexpected result with :text #51

Closed PhilippePerret closed 4 years ago

PhilippePerret commented 8 years ago
1) Form contains span with question
 Failure/Error: with_tag('span', text: dquestion[:question])

   "Par quel terme désigne-t-on le personnage le plus important du récit ?" expected within "span" in following template:
   <li id="li-q-1" data-qid="1">
   <div class="btns fright tiny">
   <a class="tiny" onclick="QuizQuestion.edit(this)" data-qid="1" data-quiz="quiz_biblio" href="javascript:void(0)">edit</a><a class="tiny" onclick="$('li#li-q-1').remove();QuizQuestion.reordonne_questions()" href="javascript:void(0)">sup</a>
   </div>
   <span>Par quel terme désigne-t-on le personnage le plus important du récit ?</span>
   </li>

For info, dquestion[:question] contains “Par quel terme désigne-t-on le personnage le plus important du récit ?”, a french question.

Question is indeed in a span tag, a exception raised though…

randoum commented 7 years ago

@PhilippePerret do you still have this issue ? Please try with 0.9.0 and paste the part of code concerned by the issue

PhilippePerret commented 7 years ago
    describe 'WITHOUT QUESTION MARK AND NON-BREAKING SPACE' do
      let(:t) { "<div><span>récit</span></div>" }
      let(:q) { "récit" }
      it '=> SUCCESS' do
        expect(t).to have_tag('div') do
          with_tag('span', text: q)
        end
      end
    end

    describe 'WITH QUESTION MARK AND COMMON SPACE' do
      let(:t) { "<div><span>récit ?</span></div>" }
      let(:q) { "récit ?" }
      it '=> SUCCESS' do
        expect(t).to have_tag('div') do
          with_tag('span', text: q)
        end
      end
    end

    describe 'WITH QUESTION MARK AND NON-BREAKING SPACE' do
      let(:t) { "<div><span>récit ?</span></div>" }
      let(:q) { "récit ?" }
      it '=> FAILURE' do
        expect(t).to have_tag('div') do
          with_tag('span', text: q)
        end
      end
    end

Note : in french, there's always a (non-breaking) space before question mark.

randoum commented 7 years ago

Your tests are all green on my side. Are you sure you are using the last version ?

PhilippePerret commented 7 years ago

Yes, randoum. Updated this morning (as you told me) -> 0.9.0

Extract of my gem list : ... rack-test (0.6.3) rake (10.4.2) rdoc (4.2.1) rspec (3.5.0) rspec-core (3.5.2) rspec-expectations (3.5.0) rspec-html-matchers (0.9.0, 0.8.0) rspec-mocks (3.5.0) rspec-support (3.5.0) rubyzip (1.2.0) sass (3.4.22) selenium-webdriver (2.53.4) ...

PhilippePerret commented 7 years ago

When you've copied-pasted my code, are you sure you still have NON-BREAKING spaces ? Sometime, when copying, non-breaking spaces become breaking spaces.

randoum commented 7 years ago

Nop, pasting your code to github certainly sanitize the strings. You need to use unicode escape codes, specially for non printable characters (as a good practice, in general).

PhilippePerret commented 7 years ago

Noticed! Thanks!

So? Have you be able to try my code with non-breaking space?

randoum commented 7 years ago

You need to paste your code with unicode escape code. I cannot guess where are your nbsp Thanks

PhilippePerret commented 7 years ago

As I told you (in first answer), non-breaking space is before question mark, in french ;-) (so we can be sure it works event without a unicode escape code — we don't use unicode escape code for non-breaking space). (on a Mac, non-breaking space can be done with ALT + SPACE) Thanks

randoum commented 7 years ago

I'm french, I know well about leading space on double punctuation.

nbsp have a value in every char table, if you work with unicode then pressing ALT+Space will transparently insert the unicode nbsp char in your string. There is no magic about pressing ALT-Space with your macintosh.

I'm asking you again: kindly paste your spec code with nsbp as unicode char.

Regards

2017-02-04 10:04 GMT+01:00 Philippe Perret notifications@github.com:

As I told you (in first answer), non-breaking space is before question mark, in french ;-) (so we can be sure it works event without a unicode escape code — we don't use unicode escape code for non-breaking space). (on a Mac, non-breaking space can be done with ALT + SPACE) Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kucaahbe/rspec-html-matchers/issues/51#issuecomment-277430251, or mute the thread https://github.com/notifications/unsubscribe-auth/ADcsyGrcvbqDj7dPjoeCn94_Ys9I_zdDks5rZD8jgaJpZM4JRwO1 .

randoum commented 4 years ago

Sorry we could not work on this. I'm closing it, reopen with more info if needed.

Cheers

PhilippePerret commented 4 years ago

randoum, je me permets de répondre en français, puisque je ne maitrise pas suffisamment l'anglais pour la finesse de dialogue que requiert ta demande.

Je sais très bien qu'il n'y a aucune magie dans l'utilisation de ALT-Space… Mais dans le code que j'ai copié, c'est un caractère unicode qui est mis (qui apparait comme une espace, puisque c'est une espace), je ne voyais pas comment remplacer un caractère unicode par un caractère unicode…

Désolé si je n'ai pas compris la demande.

randoum commented 4 years ago

Please keep it in English for other users.

I still don't have your issue. Try using the seen option