Skip to content

Commit

Permalink
Merge pull request rails#29005 from kamipo/should_escape_meta_chars_i…
Browse files Browse the repository at this point in the history
…n_regexp

Should escape meta characters in regexp
  • Loading branch information
kaspth authored May 7, 2017
2 parents af58740 + b201474 commit 45095a8
Show file tree
Hide file tree
Showing 30 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion actionmailer/test/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_deliver_is_notified
wait

assert_equal(1, @logger.logged(:info).size)
assert_match(/Sent mail to [email protected]/, @logger.logged(:info).first)
assert_match(/Sent mail to system@test\.lindsaar\.net/, @logger.logged(:info).first)

assert_equal(2, @logger.logged(:debug).size)
assert_match(/BaseMailer#welcome: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/dispatch/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class RequestIP < BaseRequestTest
request.remote_ip
}
assert_match(/IP spoofing attack/, e.message)
assert_match(/HTTP_X_FORWARDED_FOR="1.1.1.1"/, e.message)
assert_match(/HTTP_CLIENT_IP="2.2.2.2"/, e.message)
assert_match(/HTTP_X_FORWARDED_FOR="1\.1\.1\.1"/, e.message)
assert_match(/HTTP_CLIENT_IP="2\.2\.2\.2"/, e.message)
end

test "remote ip with spoof detection disabled" do
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/activerecord/controller_runtime_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_runtime_reset_before_requests
wait

assert_equal 2, @logger.logged(:info).size
assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1])
assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0\.0ms\)/, @logger.logged(:info)[1])
end

def test_log_with_active_record_when_post
Expand Down
6 changes: 3 additions & 3 deletions actionview/test/template/asset_tag_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,13 @@ def test_should_ignore_asset_host_on_scheme_relative_url

def test_should_wildcard_asset_host
@controller.config.asset_host = "http://a%d.example.com"
assert_match(%r(http://a[0123].example.com), compute_asset_host("foo"))
assert_match(%r(http://a[0123]\.example\.com), compute_asset_host("foo"))
end

def test_should_wildcard_asset_host_between_zero_and_four
@controller.config.asset_host = "http://a%d.example.com"
assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_url("xml.png"))
assert_match(%r(http://a[0123]\.example\.com/collaboration/hieraki/images/xml\.png), image_path("xml.png"))
assert_match(%r(http://a[0123]\.example\.com/collaboration/hieraki/images/xml\.png), image_url("xml.png"))
end

def test_asset_host_without_protocol_should_be_protocol_relative
Expand Down
8 changes: 4 additions & 4 deletions actionview/test/template/atom_feed_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def test_feed_should_include_atomPub_namespace
with_restful_routing(:scrolls) do
get :index, params: { id: "feed_with_atomPub_namespace" }
assert_match %r{xml:lang="en-US"}, @response.body
assert_match %r{xmlns="http://www.w3.org/2005/Atom"}, @response.body
assert_match %r{xmlns:app="http://www.w3.org/2007/app"}, @response.body
assert_match %r{xmlns="http://www\.w3\.org/2005/Atom"}, @response.body
assert_match %r{xmlns:app="http://www\.w3\.org/2007/app"}, @response.body
end
end

Expand All @@ -319,7 +319,7 @@ def test_feed_xml_processing_instructions
with_restful_routing(:scrolls) do
get :index, params: { id: "feed_with_xml_processing_instructions" }
assert_match %r{<\?xml-stylesheet [^\?]*type="text/css"}, @response.body
assert_match %r{<\?xml-stylesheet [^\?]*href="t.css"}, @response.body
assert_match %r{<\?xml-stylesheet [^\?]*href="t\.css"}, @response.body
end
end

Expand All @@ -334,7 +334,7 @@ def test_feed_xml_processing_instructions_duplicate_targets
def test_feed_xhtml
with_restful_routing(:scrolls) do
get :index, params: { id: "feed_with_xhtml_content" }
assert_match %r{xmlns="http://www.w3.org/1999/xhtml"}, @response.body
assert_match %r{xmlns="http://www\.w3\.org/1999/xhtml"}, @response.body
assert_select "summary", text: /Something Boring/
assert_select "summary", text: /after 2/
end
Expand Down
4 changes: 2 additions & 2 deletions actionview/test/template/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def fragment_cache_key(key)

def test_render_without_options
e = assert_raises(ArgumentError) { @view.render() }
assert_match(/You invoked render but did not give any of (.+) option./, e.message)
assert_match(/You invoked render but did not give any of (.+) option\./, e.message)
end

def test_render_file
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_render_error_indentation
def test_render_sub_template_with_errors
e = assert_raises(ActionView::Template::Error) { @view.render(template: "test/sub_template_raise") }
assert_match %r!method.*doesnt_exist!, e.message
assert_match %r{Trace of template inclusion: .*test/sub_template_raise.html.erb}, e.sub_template_message
assert_match %r{Trace of template inclusion: .*test/sub_template_raise\.html\.erb}, e.sub_template_message
assert_equal "1", e.line_number
assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Mysql2CharsetCollationTest < ActiveRecord::Mysql2TestCase

test "schema dump includes collation" do
output = dump_table_schema("charset_collations")
assert_match %r{t.string\s+"string_ascii_bin",\s+collation: "ascii_bin"$}, output
assert_match %r{t.text\s+"text_ucs2_unicode_ci",\s+collation: "ucs2_unicode_ci"$}, output
assert_match %r{t\.string\s+"string_ascii_bin",\s+collation: "ascii_bin"$}, output
assert_match %r{t\.text\s+"text_ucs2_unicode_ci",\s+collation: "ucs2_unicode_ci"$}, output
end
end
8 changes: 4 additions & 4 deletions activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class UnsignedType < ActiveRecord::Base

test "schema dump includes unsigned option" do
schema = dump_table_schema "unsigned_types"
assert_match %r{t.integer\s+"unsigned_integer",\s+unsigned: true$}, schema
assert_match %r{t.bigint\s+"unsigned_bigint",\s+unsigned: true$}, schema
assert_match %r{t.float\s+"unsigned_float",\s+limit: 24,\s+unsigned: true$}, schema
assert_match %r{t.decimal\s+"unsigned_decimal",\s+precision: 10,\s+scale: 2,\s+unsigned: true$}, schema
assert_match %r{t\.integer\s+"unsigned_integer",\s+unsigned: true$}, schema
assert_match %r{t\.bigint\s+"unsigned_bigint",\s+unsigned: true$}, schema
assert_match %r{t\.float\s+"unsigned_float",\s+limit: 24,\s+unsigned: true$}, schema
assert_match %r{t\.decimal\s+"unsigned_decimal",\s+precision: 10,\s+scale: 2,\s+unsigned: true$}, schema
end
end
4 changes: 2 additions & 2 deletions activerecord/test/cases/adapters/postgresql/collation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def teardown

test "schema dump includes collation" do
output = dump_table_schema("postgresql_collations")
assert_match %r{t.string\s+"string_c",\s+collation: "C"$}, output
assert_match %r{t.text\s+"text_posix",\s+collation: "POSIX"$}, output
assert_match %r{t\.string\s+"string_c",\s+collation: "C"$}, output
assert_match %r{t\.text\s+"text_posix",\s+collation: "POSIX"$}, output
end
end
4 changes: 2 additions & 2 deletions activerecord/test/cases/adapters/postgresql/explain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class PostgreSQLExplainTest < ActiveRecord::PostgreSQLTestCase

def test_explain_for_one_query
explain = Developer.where(id: 1).explain
assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
assert_match %r(EXPLAIN for: SELECT "developers"\.\* FROM "developers" WHERE "developers"\."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
assert_match %(QUERY PLAN), explain
end

def test_explain_with_eager_loading
explain = Developer.where(id: 1).includes(:audit_logs).explain
assert_match %(QUERY PLAN), explain
assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
assert_match %r(EXPLAIN for: SELECT "developers"\.\* FROM "developers" WHERE "developers"\."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" = 1), explain
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_only_warn_on_first_encounter_of_unknown_oid
@connection.select_all "SELECT NULL::anyelement"
@connection.select_all "SELECT NULL::anyelement"
}
assert_match(/\Aunknown OID \d+: failed to recognize type of 'anyelement'. It will be treated as String.\n\z/, warning)
assert_match(/\Aunknown OID \d+: failed to recognize type of 'anyelement'\. It will be treated as String\.\n\z/, warning)
ensure
reset_connection
end
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/adapters/sqlite3/collation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def teardown

test "schema dump includes collation" do
output = dump_table_schema("collation_table_sqlite3")
assert_match %r{t.string\s+"string_nocase",\s+collation: "NOCASE"$}, output
assert_match %r{t.text\s+"text_rtrim",\s+collation: "RTRIM"$}, output
assert_match %r{t\.string\s+"string_nocase",\s+collation: "NOCASE"$}, output
assert_match %r{t\.text\s+"text_rtrim",\s+collation: "RTRIM"$}, output
end
end
4 changes: 2 additions & 2 deletions activerecord/test/cases/adapters/sqlite3/explain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class SQLite3ExplainTest < ActiveRecord::SQLite3TestCase

def test_explain_for_one_query
explain = Developer.where(id: 1).explain
assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\? \[\["id", 1\]\]|1)), explain
assert_match %r(EXPLAIN for: SELECT "developers"\.\* FROM "developers" WHERE "developers"\."id" = (?:\? \[\["id", 1\]\]|1)), explain
assert_match(/(SEARCH )?TABLE developers USING (INTEGER )?PRIMARY KEY/, explain)
end

def test_explain_with_eager_loading
explain = Developer.where(id: 1).includes(:audit_logs).explain
assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\? \[\["id", 1\]\]|1)), explain
assert_match %r(EXPLAIN for: SELECT "developers"\.\* FROM "developers" WHERE "developers"\."id" = (?:\? \[\["id", 1\]\]|1)), explain
assert_match(/(SEARCH )?TABLE developers USING (INTEGER )?PRIMARY KEY/, explain)
assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" = 1), explain
assert_match(/(SCAN )?TABLE audit_logs/, explain)
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/batches_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_find_in_batches_shouldnt_execute_query_unless_needed

def test_find_in_batches_should_quote_batch_order
c = Post.connection
assert_sql(/ORDER BY #{c.quote_table_name('posts')}.#{c.quote_column_name('id')}/) do
assert_sql(/ORDER BY #{c.quote_table_name('posts')}\.#{c.quote_column_name('id')}/) do
Post.find_in_batches(batch_size: 1) do |batch|
assert_kind_of Array, batch
assert_kind_of Post, batch.first
Expand Down Expand Up @@ -408,7 +408,7 @@ def test_in_batches_shouldnt_execute_query_unless_needed

def test_in_batches_should_quote_batch_order
c = Post.connection
assert_sql(/ORDER BY #{c.quote_table_name('posts')}.#{c.quote_column_name('id')}/) do
assert_sql(/ORDER BY #{c.quote_table_name('posts')}\.#{c.quote_column_name('id')}/) do
Post.in_batches(of: 1) do |relation|
assert_kind_of ActiveRecord::Relation, relation
assert_kind_of Post, relation.first
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/inheritance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_alt_eager_loading

def test_eager_load_belongs_to_primary_key_quoting
con = Account.connection
assert_sql(/#{con.quote_table_name('companies')}.#{con.quote_column_name('id')} = 1/) do
assert_sql(/#{con.quote_table_name('companies')}\.#{con.quote_column_name('id')} = 1/) do
Account.all.merge!(includes: :firm).find(1)
end
end
Expand Down
16 changes: 8 additions & 8 deletions activerecord/test/cases/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_basic_payload_name_logging_coloration_generic_sql
logger.colorize_logging = true
SQL_COLORINGS.each do |verb, _|
logger.sql(Event.new(0, sql: verb.to_s))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0\.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)

logger.sql(Event.new(0, sql: verb.to_s, name: "SQL"))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA}SQL \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
Expand All @@ -109,13 +109,13 @@ def test_basic_payload_name_logging_coloration_named_sql
logger.colorize_logging = true
SQL_COLORINGS.each do |verb, _|
logger.sql(Event.new(0, sql: verb.to_s, name: "Model Load"))
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Load \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Load \(0\.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)

logger.sql(Event.new(0, sql: verb.to_s, name: "Model Exists"))
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Exists \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Exists \(0\.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)

logger.sql(Event.new(0, sql: verb.to_s, name: "ANY SPECIFIC NAME"))
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}ANY SPECIFIC NAME \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}ANY SPECIFIC NAME \(0\.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last)
end
end

Expand All @@ -124,7 +124,7 @@ def test_query_logging_coloration_with_nested_select
logger.colorize_logging = true
SQL_COLORINGS.slice(:SELECT, :INSERT, :UPDATE, :DELETE).each do |verb, color_regex|
logger.sql(Event.new(0, sql: "#{verb} WHERE ID IN SELECT"))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{color_regex}#{verb} WHERE ID IN SELECT#{REGEXP_CLEAR}/i, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0\.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{color_regex}#{verb} WHERE ID IN SELECT#{REGEXP_CLEAR}/i, logger.debugs.last)
end
end

Expand All @@ -139,7 +139,7 @@ def test_query_logging_coloration_with_multi_line_nested_select
)
EOS
logger.sql(Event.new(0, sql: sql))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{color_regex}.*#{verb}.*#{REGEXP_CLEAR}/mi, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0\.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{color_regex}.*#{verb}.*#{REGEXP_CLEAR}/mi, logger.debugs.last)
end
end

Expand All @@ -152,13 +152,13 @@ def test_query_logging_coloration_with_lock
WHERE col1 = 5;
EOS
logger.sql(Event.new(0, sql: sql))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{SQL_COLORINGS[:LOCK]}.*FOR UPDATE.*#{REGEXP_CLEAR}/mi, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0\.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{SQL_COLORINGS[:LOCK]}.*FOR UPDATE.*#{REGEXP_CLEAR}/mi, logger.debugs.last)

sql = <<-EOS
LOCK TABLE films IN SHARE MODE;
EOS
logger.sql(Event.new(0, sql: sql))
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{SQL_COLORINGS[:LOCK]}.*LOCK TABLE.*#{REGEXP_CLEAR}/mi, logger.debugs.last)
assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0\.0ms\)#{REGEXP_CLEAR} #{REGEXP_BOLD}#{SQL_COLORINGS[:LOCK]}.*LOCK TABLE.*#{REGEXP_CLEAR}/mi, logger.debugs.last)
end

def test_exists_query_logging
Expand Down
4 changes: 2 additions & 2 deletions activesupport/test/testing/file_fixtures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FileFixturesTest < ActiveSupport::TestCase
test "#file_fixture returns Pathname to file fixture" do
path = file_fixture("sample.txt")
assert_kind_of Pathname, path
assert_match %r{.*/test/file_fixtures/sample.txt$}, path.to_s
assert_match %r{.*/test/file_fixtures/sample\.txt$}, path.to_s
end

test "raises an exception when the fixture file does not exist" do
Expand All @@ -25,6 +25,6 @@ class FileFixturesPathnameDirectoryTest < ActiveSupport::TestCase
test "#file_fixture_path returns Pathname to file fixture" do
path = file_fixture("sample.txt")
assert_kind_of Pathname, path
assert_match %r{.*/test/file_fixtures/sample.txt$}, path.to_s
assert_match %r{.*/test/file_fixtures/sample\.txt$}, path.to_s
end
end
2 changes: 1 addition & 1 deletion activesupport/test/time_travel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_time_helper_travel_to_with_nested_calls_with_blocks
#noop
end
end
assert_match(/Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing./, e.message)
assert_match(/Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing\./, e.message)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion guides/source/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest
assert_equal "You have been invited by [email protected]", invite_email.subject
assert_equal '[email protected]', invite_email.to[0]
assert_match(/Hi [email protected]/, invite_email.body.to_s)
assert_match(/Hi friend@example\.com/, invite_email.body.to_s)
end
end
```
Expand Down
14 changes: 7 additions & 7 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ def test_evented_file_update_checker_config
run_generator
assert_file "config/environments/development.rb" do |content|
if RbConfig::CONFIG["host_os"] =~ /darwin|linux/
assert_match(/^\s*config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
assert_match(/^\s*config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
else
assert_match(/^\s*# config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
assert_match(/^\s*# config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
end
end
end
Expand Down Expand Up @@ -639,7 +639,7 @@ def test_web_console_with_dev_option

assert_file "Gemfile" do |content|
assert_match(/gem 'web-console',\s+github: 'rails\/web-console'/, content)
assert_no_match(/\Agem 'web-console', '>= 3.3.0'\z/, content)
assert_no_match(/\Agem 'web-console', '>= 3\.3\.0'\z/, content)
end
end

Expand All @@ -648,7 +648,7 @@ def test_web_console_with_edge_option

assert_file "Gemfile" do |content|
assert_match(/gem 'web-console',\s+github: 'rails\/web-console'/, content)
assert_no_match(/\Agem 'web-console', '>= 3.3.0'\z/, content)
assert_no_match(/\Agem 'web-console', '>= 3\.3\.0'\z/, content)
end
end

Expand Down Expand Up @@ -787,7 +787,7 @@ def test_create_keeps

def test_psych_gem
run_generator
gem_regex = /gem 'psych',\s+'~> 2.0',\s+platforms: :rbx/
gem_regex = /gem 'psych',\s+'~> 2\.0',\s+platforms: :rbx/

assert_file "Gemfile" do |content|
if defined?(Rubinius)
Expand Down Expand Up @@ -870,7 +870,7 @@ def assert_listen_related_configuration
assert_gem "spring-watcher-listen"

assert_file "config/environments/development.rb" do |content|
assert_match(/^\s*config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
assert_match(/^\s*config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
end
end

Expand All @@ -880,7 +880,7 @@ def assert_no_listen_related_configuration
end

assert_file "config/environments/development.rb" do |content|
assert_match(/^\s*# config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
assert_match(/^\s*# config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
end
end

Expand Down
4 changes: 2 additions & 2 deletions railties/test/generators/channel_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_channel_is_created
end

assert_file "app/assets/javascripts/channels/chat.js" do |channel|
assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel)
assert_match(/App\.chat = App\.cable\.subscriptions\.create\("ChatChannel/, channel)
end
end

Expand All @@ -39,7 +39,7 @@ def test_channel_with_multiple_actions_is_created
end

assert_file "app/assets/javascripts/channels/chat.js" do |channel|
assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel)
assert_match(/App\.chat = App\.cable\.subscriptions\.create\("ChatChannel/, channel)
assert_match(/,\n\n speak/, channel)
assert_match(/,\n\n mute: function\(\) \{\n return this\.perform\('mute'\);\n \}\n\}\);/, channel)
end
Expand Down
Loading

0 comments on commit 45095a8

Please sign in to comment.