diff options
-rw-r--r-- | lib/custodian/protocoltest/http.rb | 4 | ||||
-rwxr-xr-x | t/test-custodian-parser.rb | 22 |
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index 6e0985d..3bc4b05 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -114,8 +114,8 @@ module Custodian # # The content we expect to find # - if line =~ /with content ["']([^'"]+)['"]/ - @expected_content = $1.dup + if line =~ /with content (["'])(.*)\1/ + @expected_content = $2.dup else @expected_content = nil end diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index ddc1153..d9420a5 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -368,6 +368,28 @@ EOF end end + # + # Test that we can use lots of different strings for content. + # + def test_http_with_content_parsing + content_strings = [ + "'bar in single quotes'", + '"bar in double quotes"', + "'bar in single quotes with \"embedded double quotes\"'", + '"bar in double quotes with \'embedded double quotes\'"', + ] + + content_strings.each do |cs| + str = "http://example must run http with content #{cs}." + obj = Custodian::TestFactory.create(str) + assert(!obj.nil?) + assert(obj.kind_of? Array) + assert(obj.size == 1) + + assert_equal(obj[0].to_s, str) + assert_equal(cs[1..-2], obj[0].expected_content) + end + end # |