1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
Description: Force encoding of expected results to ASCII-8BIT
Ruby2.0 defaults to UTF-8, whereas strings @s are ASCII-8BIT
Bug: https://github.com/astro/remcached/issues/5
Forwarded: https://github.com/astro/remcached/pull/6
Author: Cédric Boutillier <boutil@debian.org>
Last-Update: 2014-04-26
--- a/spec/packet_spec.rb
+++ b/spec/packet_spec.rb
@@ -16,13 +16,13 @@
end
it "should serialize correctly" do
- @s.should == "\x80\x00\x00\x05" +
+ @s.should == ("\x80\x00\x00\x05" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x05" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
- "Hello"
+ "Hello").force_encoding("ASCII-8BIT")
end
end
@@ -36,7 +36,7 @@
end
it "should serialize correctly" do
- @s.should == "\x80\x02\x00\x05" +
+ @s.should == ("\x80\x02\x00\x05" +
"\x08\x00\x00\x00" +
"\x00\x00\x00\x12" +
"\x00\x00\x00\x00" +
@@ -45,7 +45,7 @@
"\xde\xad\xbe\xef" +
"\x00\x00\x0e\x10" +
"Hello" +
- "World"
+ "World").force_encoding("ASCII-8BIT")
end
end
end
@@ -53,10 +53,10 @@
context "when parsing a response" do
context "example 4.1.1" do
before :all do
- s = "\x81\x00\x00\x00\x00\x00\x00\x01" +
+ s = ("\x81\x00\x00\x00\x00\x00\x00\x01" +
"\x00\x00\x00\x09\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00" +
- "Not found"
+ "Not found").force_encoding("ASCII-8BIT")
@pkt = Memcached::Response.parse_header(s[0..23])
@pkt.parse_body(s[24..-1])
end
@@ -87,14 +87,14 @@
context "example 4.2.1" do
before :all do
- s = "\x81\x00\x00\x00" +
+ s = ("\x81\x00\x00\x00" +
"\x04\x00\x00\x00" +
"\x00\x00\x00\x09" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x01" +
"\xde\xad\xbe\xef" +
- "World"
+ "World").force_encoding("ASCII-8BIT")
@pkt = Memcached::Response.parse_header(s[0..23])
@pkt.parse_body(s[24..-1])
end
|