spec/rflow_message_spec.rb in rflow-0.0.5 vs spec/rflow_message_spec.rb in rflow-1.0.0a1

- old
+ new

@@ -48,11 +48,11 @@ context "if created with a serialized data object" do before(:all) do @string = 'this is a string to be serialized' @avro_serialized_string = encode_avro(@avro_string_schema_string, @string) end - + it "should instantiate correctly" do expect {RFlow::Message.new('string_type', [], 'avro', nil, @avro_serialized_string)}.to_not raise_error message = RFlow::Message.new('string_type', [], 'avro', nil, @avro_serialized_string) end end @@ -63,16 +63,16 @@ context "if created with invalid provenance" do before(:all) do @invalid_processing_event_hash = {'started_at' => 'bad time string'} @invalid_provenance = [@invalid_processing_event_hash] end - + it "should throw an exception" do expect {RFlow::Message.new('string_type', @invalid_provenance)}.to raise_error(ArgumentError) end end - + context "if created with valid provenance" do before(:all) do @valid_xmlschema_time = '2001-01-01T01:01:01.000001Z' @valid_processing_event_hash = {'component_instance_uuid' => 'uuid', 'started_at' => @valid_xmlschema_time} @valid_processing_event = RFlow::Message::ProcessingEvent.new('uuid', @valid_xmlschema_time, @valid_xmlschema_time, 'context') @@ -85,11 +85,11 @@ {"component_instance_uuid"=>"uuid", "started_at"=>nil, "completed_at"=>nil, "context"=>nil}, {"component_instance_uuid"=>"uuid", "started_at"=>@valid_xmlschema_time, "completed_at"=>nil, "context"=>nil}, {"component_instance_uuid"=>"uuid", "started_at"=>@valid_xmlschema_time, "completed_at"=>@valid_xmlschema_time, "context"=>"context"}, ] end - + it "should instantiate correctly" do p @valid_provenance expect {RFlow::Message.new('string_type', @valid_provenance)}.to_not raise_error end @@ -103,11 +103,11 @@ it "should to_hash its provenance correctly" do message = RFlow::Message.new('string_type', @valid_provenance) message.provenance.map(&:to_hash).should == @valid_provenance_hashes end - + end context "if correctly created" do it "should serialize and deserialized correctly to/from avro" do message = RFlow::Message.new('string_type') @@ -117,11 +117,11 @@ processed_message = RFlow::Message.from_avro(message.to_avro) message.data.to_avro.should == processed_message.data.to_avro message.data.data_object.should == processed_message.data.data_object end end - + context "if data extensions exist" do it "should extend the data element with the extension" do module ExtensionModule; def ext_method; end; end message = RFlow::Message.new('string_type') @@ -136,47 +136,47 @@ end it "should correctly handle large raw types" do message = RFlow::Message.new('RFlow::Message::Data::Raw') message.data.raw = Array.new(101) { rand(256) }.pack('c*') - + message_avro = message.to_avro.force_encoding('BINARY') - + processed_message = RFlow::Message.from_avro(message_avro) processed_message_avro = processed_message.to_avro.force_encoding('BINARY') @raw_schema = RFlow::Configuration.available_data_types['RFlow::Message::Data::Raw']['avro'] encode_avro(@raw_schema, message.data.data_object).should == message.data.to_avro decode_avro(@raw_schema, message.data.to_avro).should == message.data.data_object - + p message.data.raw p message_avro p message_avro.bytesize p processed_message_avro p processed_message_avro.bytesize - + p message_avro.encoding p message_avro.valid_encoding? p processed_message_avro.encoding p processed_message_avro.valid_encoding? message_data_avro = message.data.to_avro.force_encoding('BINARY') processed_message_data_avro = processed_message.data.to_avro.force_encoding('BINARY') - + p message_data_avro.encoding p message_data_avro.valid_encoding? p message_data_avro p processed_message_data_avro.encoding p processed_message_data_avro.valid_encoding? p processed_message_data_avro Digest::MD5.hexdigest(message_avro).should == Digest::MD5.hexdigest(processed_message_avro) - + message_data_avro.should == processed_message_data_avro Digest::MD5.hexdigest(message_data_avro).should == Digest::MD5.hexdigest(processed_message_data_avro) Digest::MD5.hexdigest(message.data.raw).should == Digest::MD5.hexdigest(processed_message.data.raw) end - + end