From 26b64cacfe57c021be4e416f73597f1fa9801515 Mon Sep 17 00:00:00 2001 From: lanzhiheng Date: Sat, 21 Apr 2018 16:35:44 +0800 Subject: [PATCH] Fix we can not input jquery code without semicolon. --- lib/jquery/assert_select.rb | 2 +- test/assert_select_jquery_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jquery/assert_select.rb b/lib/jquery/assert_select.rb index bae783e0..debf99d1 100644 --- a/lib/jquery/assert_select.rb +++ b/lib/jquery/assert_select.rb @@ -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 diff --git a/test/assert_select_jquery_test.rb b/test/assert_select_jquery_test.rb index ed93d519..90c6dcb0 100644 --- a/test/assert_select_jquery_test.rb +++ b/test/assert_select_jquery_test.rb @@ -1,3 +1,4 @@ +require 'ostruct' require_relative 'test_helper' require_relative '../lib/jquery/assert_select' @@ -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 @@ -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