spec/riak/serializers_spec.rb in riak-client-2.2.0.pre1 vs spec/riak/serializers_spec.rb in riak-client-2.2.0

- old
+ new

@@ -6,26 +6,33 @@ it "serializes #{deserialized} to #{serialized}" do expect(described_class.serialize(type, deserialized)).to eq(serialized) end it "deserializes #{serialized} to #{deserialized}" do - expect(described_class.deserialize(type, serialized)).to eq(deserialized) + expect(described_class.deserialize(type, serialized)). + to eq(deserialized) end it "round trips properly" do str = described_class.serialize(type, deserialized) expect(described_class.deserialize(type, str)).to eq(deserialized) end end end it_behaves_like "a serializer", "text/plain", "a string", "a string" - it_behaves_like "a serializer", "application/json", { "a" => 7 }, %q|{"a":7}| - it_behaves_like "a serializer", "application/x-ruby-marshal", { :a => 3 }, Marshal.dump({ :a => 3 }) + it_behaves_like "a serializer", "application/json", { "a" => 7 }, '{"a":7}' + it_behaves_like "a serializer", + "application/x-ruby-marshal", + { a: 3 }, + Marshal.dump({ a: 3 }) described_class::YAML_MIME_TYPES.each do |mime_type| - it_behaves_like "a serializer", mime_type, { "a" => 7 }, YAML.dump({ "a" => 7 }) + it_behaves_like "a serializer", + mime_type, + { "a" => 7 }, + YAML.dump({ "a" => 7 }) end %w[ serialize deserialize ].each do |meth| describe ".#{meth}" do it 'raises an IOError when given an unrecognized content type' do @@ -36,11 +43,12 @@ end end describe "plain text serializer" do it 'calls #to_s to convert the object to a string' do - expect(described_class.serialize("text/plain", :a_string)).to eq("a_string") + expect(described_class.serialize('text/plain', :a_string)). + to eq('a_string') end end describe "JSON serializer" do it "respects the max nesting option" do @@ -78,15 +86,19 @@ end end it 'can be registered' do described_class['application/custom-type-1'] = custom_serializer - expect(described_class['application/custom-type-1']).to be(custom_serializer) + expect(described_class['application/custom-type-1']). + to be(custom_serializer) # fail end - it_behaves_like "a serializer", "application/custom-type-a", "foo", "The string is: foo" do + it_behaves_like "a serializer", + "application/custom-type-a", + "foo", + "The string is: foo" do before(:each) do described_class['application/custom-type-a'] = custom_serializer end end @@ -96,9 +108,14 @@ described_class.send(:serializers).delete(ctype) end end end - it_behaves_like "a serializer", "application/json; charset=UTF-8", { "a" => 7 }, %q|{"a":7}| - it_behaves_like "a serializer", "application/json ;charset=UTF-8", { "a" => 7 }, %q|{"a":7}| + it_behaves_like "a serializer", + "application/json; charset=UTF-8", + { "a" => 7 }, + '{"a":7}' + it_behaves_like "a serializer", + "application/json ;charset=UTF-8", + { "a" => 7 }, + '{"a":7}' end -