From 1e6dcbee1f5b8ab6e4ad724fe642fb5998d573d1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 27 Apr 2015 21:35:27 +0200 Subject: [PATCH] Improved regular expressions. --- test/integration/user_agent_test.rb | 26 +++++++++++++------------- test/unit/email_build_test.rb | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/integration/user_agent_test.rb b/test/integration/user_agent_test.rb index 68cc6c7ce..bb40ca000 100644 --- a/test/integration/user_agent_test.rb +++ b/test/integration/user_agent_test.rb @@ -18,7 +18,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"get"/) assert(result.body =~ /"123"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # get / 404 result = UserAgent.get( @@ -42,7 +42,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"post"/) assert(result.body =~ /"some value"/) - assert(result.body =~ /"application\/x-www-form-urlencoded"/) + assert(result.body =~ %r{"application/x-www-form-urlencoded"}) # post / 404 result = UserAgent.post( @@ -69,7 +69,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"put"/) assert(result.body =~ /"some value"/) - assert(result.body =~ /"application\/x-www-form-urlencoded"/) + assert(result.body =~ %r{"application/x-www-form-urlencoded"}) # put / 404 result = UserAgent.put( @@ -92,7 +92,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal('200', result.code) assert_equal(String, result.body.class) assert(result.body =~ /"delete"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # delete / 404 result = UserAgent.delete( @@ -120,7 +120,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"get"/) assert(result.body =~ /"123"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # get / 401 result = UserAgent.get( @@ -153,7 +153,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"post"/) assert(result.body =~ /"some value"/) - assert(result.body =~ /"application\/x-www-form-urlencoded"/) + assert(result.body =~ %r{"application/x-www-form-urlencoded"}) # post / 401 result = UserAgent.post( @@ -188,7 +188,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"put"/) assert(result.body =~ /"some value"/) - assert(result.body =~ /"application\/x-www-form-urlencoded"/) + assert(result.body =~ %r{"application/x-www-form-urlencoded"}) # put / 401 result = UserAgent.put( @@ -219,7 +219,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal('200', result.code) assert_equal(String, result.body.class) assert(result.body =~ /"delete"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # delete / 401 result = UserAgent.delete( @@ -248,7 +248,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"get"/) assert(result.body =~ /"abc"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # get / 301 result = UserAgent.request( @@ -264,7 +264,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"get"/) assert(result.body =~ /"abc"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # get / 401 result = UserAgent.request( @@ -293,7 +293,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal(String, result.body.class) assert(result.body =~ /"get"/) assert(result.body =~ /"123"/) - assert(result.body =~ /"text\/plain"/) + assert(result.body =~ %r{"text/plain"}) # ftp / 200 result = UserAgent.request( @@ -430,7 +430,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal('200', result.code) assert_equal(String, result.body.class) assert(result.body =~ /"content_type_requested"/) - assert(result.body =~ /"application\/json"/) + assert(result.body =~ %r{"application/json"}) assert_equal('some value ', result.data['submitted']['key']) # get / 401 @@ -464,7 +464,7 @@ class UserAgentTest < ActiveSupport::TestCase assert_equal('201', result.code) assert_equal(String, result.body.class) assert(result.body =~ /"content_type_requested"/) - assert(result.body =~ /"application\/json"/) + assert(result.body =~ %r{"application/json"}) assert_equal('some value ', result.data['submitted']['key']) end diff --git a/test/unit/email_build_test.rb b/test/unit/email_build_test.rb index b8efa307c..cfd7f8165 100644 --- a/test/unit/email_build_test.rb +++ b/test/unit/email_build_test.rb @@ -11,7 +11,7 @@ class EmailBuildTest < ActiveSupport::TestCase assert( result !~ /^.+?<\!DOCTYPE/, 'test 1') assert( result =~ //, 'test 1') assert( result =~ /font-family/, 'test 1') - assert( result =~ /test<\/b>/, 'test 1') + assert( result =~ %r{test}, 'test 1') html = 'invalid test' result = Channel::EmailBuild.html_complete_check( html ) @@ -20,7 +20,7 @@ class EmailBuildTest < ActiveSupport::TestCase assert( result =~ /^.+?<\!DOCTYPE/, 'test 2') assert( result =~ //, 'test 2') assert( result !~ /font-family/, 'test 2') - assert( result =~ /test<\/b>/, 'test 2') + assert( result =~ %r{test}, 'test 2') end