spec/codecs/plain_spec.rb in logstash-codec-plain-2.0.4 vs spec/codecs/plain_spec.rb in logstash-codec-plain-3.0.0

- old
+ new

@@ -17,23 +17,23 @@ it "should decode valid UTF-8 input" do ["foobar", "κόσμε"].each do |data| insist { data.encoding.name } == "UTF-8" insist { data.valid_encoding? } == true subject.decode(data) do |event| - insist { event["message"] } == data - insist { event["message"].encoding.name } == "UTF-8" + insist { event.get("message") } == data + insist { event.get("message").encoding.name } == "UTF-8" end end end it "should escape invalid sequences" do ["foo \xED\xB9\x81\xC3", "bar \xAD"].each do |data| insist { data.encoding.name } == "UTF-8" insist { data.valid_encoding? } == false subject.decode(data) do |event| - insist { event["message"] } == data.inspect[1..-2] - insist { event["message"].encoding.name } == "UTF-8" + insist { event.get("message") } == data.inspect[1..-2] + insist { event.get("message").encoding.name } == "UTF-8" end end end end @@ -51,12 +51,12 @@ insist { a.encoding.name } == "ISO-8859-1" insist { b.encoding.name } == "UTF-8" insist { a.valid_encoding? } == true subject.decode(a) do |event| - insist { event["message"] } == b - insist { event["message"].encoding.name } == "UTF-8" + insist { event.get("message") } == b + insist { event.get("message").encoding.name } == "UTF-8" end end end end @@ -73,21 +73,21 @@ insist { a.encoding.name } == "ASCII-8BIT" insist { b.encoding.name } == "UTF-8" insist { a.valid_encoding? } == true subject.decode(a) do |event| - insist { event["message"] } == b - insist { event["message"].encoding.name } == "UTF-8" + insist { event.get("message") } == b + insist { event.get("message").encoding.name } == "UTF-8" end end end end end context "#encode" do it "should return a plain text encoding" do event = LogStash::Event.new - event["message"] = "Hello World." + event.set("message", "Hello World.") subject.on_event do |event, data| insist { data } == event.to_s end subject.encode(event) end