rails / jquery-rails

A gem to automate using jQuery with Rails
MIT License
948 stars 406 forks source link

Allow whitespace before method call in assert_select_jquery #153

Closed georgeclaghorn closed 10 years ago

georgeclaghorn commented 10 years ago

In JavaScript, whitespace is permitted between chained function calls, like so:

$('#new_subscription')
  .append("<p class=\"message success\"><i class=\"fa fa-check\"></i> You&rsquo;ve been added to the mailing list. Thanks!</p>")
  .find('input[type=email]')
  .val('');

The following assertion using assert_select_jquery fails on the above example with the latest version of the jquery-rails gem:

assert_select_jquery :append, '#new_subscription'

The assertion fails because assert_select_jquery assumes no whitespace between the jQuery call and the append method call. This pull request modifies the regular expression generated in assert_select_jquery to permit legal whitespace.