jquery-rails icon indicating copy to clipboard operation
jquery-rails copied to clipboard

assert_select_jquery not working with space inside ()

Open respire opened this issue 9 years ago • 1 comments

Example

in js

$( "#cart" ).html( "<%= escape_javascript render(@cart) %>" );

in test

assert_select_jquery :html, '#cart' do
    # some codes
end

result in

No JQuery call matches [:html, "#cart"]

Related code

(lib/jquery/assert_select.rb:53)

pattern = "\\s*\\.#{jquery_method || '\\w+'}\\("

(lib/jquery/assert_select.rb:56)

pattern = "(?:jQuery|\\$)\\(['\"]#{id}['\"]\\)#{pattern}" if id

My Solution ( add "\s?" )

(lib/jquery/assert_select.rb:53)

pattern = "\\s*\\.#{jquery_method || '\\w+'}\\(\\s?"

(lib/jquery/assert_select.rb:56)

pattern = "(?:jQuery|\\$)\\(\\s?['\"]#{id}['\"]\\s?\\)#{pattern}" if id

respire avatar Mar 04 '15 05:03 respire

Could you open a PR?

rafaelfranca avatar Sep 01 '15 05:09 rafaelfranca