@@ -24,34 +24,34 @@ class SprocketsRendererTest < ActiveSupport::TestCase
2424
2525 test '#render replays console messages' do
2626 result = @renderer . render ( "TodoListWithConsoleLog" , { todos : [ "log some messages" ] } )
27- assert_match ( ' console.log.apply(console, ["got initial state"])' , result )
28- assert_match ( ' console.warn.apply(console, ["mounted component"])' , result )
29- assert_match ( ' console.error.apply(console, ["rendered!","foo"])' , result )
27+ assert_match ( / console.log.apply\ ( console, \ [ "got initial state"\] \) / , result )
28+ assert_match ( / console.warn.apply\ ( console, \ [ "mounted component"\] \) / , result )
29+ assert_match ( / console.error.apply\ ( console, \ [ "rendered!","foo"\] \) / , result )
3030 end
3131
3232 test '#render console messages can be disabled' do
3333 no_log_renderer = React ::ServerRendering ::SprocketsRenderer . new ( { replay_console : false } )
3434 result = no_log_renderer . render ( "TodoListWithConsoleLog" , { todos : [ "log some messages" ] } )
35- assert_no_match ( ' console.log.apply(console, ["got initial state"])' , result )
36- assert_no_match ( ' console.warn.apply(console, ["mounted component"])' , result )
37- assert_no_match ( ' console.error.apply(console, ["rendered!","foo"])' , result )
35+ assert_no_match ( / console.log.apply\ ( console, \ [ "got initial state"\] \) / , result )
36+ assert_no_match ( / console.warn.apply\ ( console, \ [ "mounted component"\] \) / , result )
37+ assert_no_match ( / console.error.apply\ ( console, \ [ "rendered!","foo"\] \) / , result )
3838 end
3939
4040 test '#render errors include stack traces' do
4141 err = assert_raises React ::ServerRendering ::SprocketsRenderer ::PrerenderError do
4242 @renderer . render ( "NonExistentComponent" , { } )
4343 end
44- assert_match ( " ReferenceError" , err . to_s )
45- assert_match ( " NonExistentComponent" , err . to_s , "it names the component" )
44+ assert_match ( / ReferenceError/ , err . to_s )
45+ assert_match ( / NonExistentComponent/ , err . to_s , "it names the component" )
4646 assert_match ( /\n / , err . to_s , "it includes the multi-line backtrace" )
4747 end
4848
4949 test '.new accepts any filenames' do
5050 limited_renderer = React ::ServerRendering ::SprocketsRenderer . new ( files : [ "react.js" , "components/Todo.js" ] )
51- assert_match ( " get a real job</li>" , limited_renderer . render ( "Todo" , { todo : "get a real job" } ) )
51+ assert_match ( / get a real job<\ / li>/ , limited_renderer . render ( "Todo" , { todo : "get a real job" } ) )
5252 err = assert_raises React ::ServerRendering ::SprocketsRenderer ::PrerenderError do
5353 limited_renderer . render ( "TodoList" , { todos : [ ] } )
5454 end
55- assert_match ( " ReferenceError" , err . to_s , "it doesnt load other files" )
55+ assert_match ( / ReferenceError/ , err . to_s , "it doesnt load other files" )
5656 end
5757end
0 commit comments