#352 new
dan aronson

bug introduced in latest version of webrat

Reported by dan aronson | February 1st, 2010 @ 06:42 PM

This commit: http://github.com/brynary/webrat/commit/db168bedec17c92a591ab598458... seems to be broken.

Removing whitespaces is wrong since what we are checking for might be expecting the white spaces. In fact several of our tests broke because of this

Comments and changes to this ticket

  • Shannon -jj Behrens

    Shannon -jj Behrens June 10th, 2010 @ 05:41 PM

    Yep, this broke my tests too.

    When I upgraded from webrat 0.6.0 to 0.7.0, some of my tests
    started failing. I had a test that said:

    And I should see "The queue is out of sync with the server. Please reload the page."

    The problem is that there are two spaces after the period. When
    Webrat tries to match the string against the HTML, it modifies the
    HTML so that multiple spaces are treated as a single space. That
    means that even though I copied the message straight out of the code,
    this test can't possibly pass. I think that if Webrat modifies the
    HTML, then it should probably do the same thing to the string in the
    test.

    Here's the problematic code in webrat:

    module Webrat
    module Matchers

    class HasContent #:nodoc:

     def initialize(content)
       @content = content
     end
    
     def matches?(stringlike)
       @document = Webrat::XML.document(stringlike)
       @element = @document.inner_text
    
       case @content
       when String
         @element.gsub(/\s+/, ' ').include?(@content)       <----------
       when Regexp
         @element.match(@content)
       end
     end
    
  • Alex Ooi

    Alex Ooi August 12th, 2010 @ 02:43 AM

    • Milestone order changed from “0” to “0”

    i second this ... it really pissed me off that my tests broke because the HasContent matcher was altering the raw content...

    there really shouldn't be any reason why the matcher should alter the raw content. After all, the raw content is what you want to assert on! To change it under the covers is to introduce magic and complexity into what is already an otherwise very complex and magical stack

    anyway, i think this should be fixed to remove the gsub... i've done this in my local gem version and vendor-gemmed it into my project. this is just a hack solution. the ideal solution is to fix it in the source code so that future gem installs will get a fixed version of this code

  • mostpha mostpha

    mostpha mostpha February 11th, 2020 @ 02:07 AM

    https://www.rjeem.com/
    https://www.rjeem.com/praying-istikhaarah-without-prayer/
    https://www.rjeem.com/the-most-beautiful-romantic-images-romantic-f...
    anyway, i think this should be fixed to remove the gsub... i've done this in my local gem version and vendor-gemmed it into my project. this is just a hack solution. the ideal solution is to fix it in the source code so that future gem installs will get a fixed version of this code

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Pages