Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix we can not input jquery code without semicolon. #255

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jquery/assert_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions

PATTERN_HTML = "['\"]((\\\\\"|\\\\'|[^\"'])*)['\"]"
PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\);"
SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\)[;]?"

def assert_select_jquery(*args, &block)
jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
Expand Down
5 changes: 5 additions & 0 deletions test/assert_select_jquery_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'ostruct'
require_relative 'test_helper'
require_relative '../lib/jquery/assert_select'

Expand All @@ -19,6 +20,9 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
$("#cart tr:not(.total_line) > *").remove();
$("[href|=\"val\"][href$=\"val\"][href^=\"val\"]").remove();
$("tr + td, li").remove();

// without semicolon
$("#browser_cart").hide("blind", 1000)
JS

setup do
Expand All @@ -28,6 +32,7 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
def test_target_as_receiver
assert_nothing_raised do
assert_select_jquery :show, :blind, '#card'
assert_select_jquery :hide, :blind, '#browser_cart'
assert_select_jquery :html, '#id' do
assert_select 'p', 'something'
end
Expand Down