spec/spec_helper.rb in rflow-1.0.0a1 vs spec/spec_helper.rb in rflow-1.0.0a2
- old
+ new
@@ -1,14 +1,18 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rflow'))
require 'fileutils'
require 'log4r'
+require 'rspec/collection_matchers'
+I18n.enforce_available_locales = true
+
RSpec.configure do |config|
config.before(:all) do
RFlow.logger = Log4r::Logger.new 'test'
RFlow.logger.add Log4r::StdoutOutputter.new('test_stdout', :formatter => RFlow::Logger::LOG_PATTERN_FORMATTER)
+ RFlow.logger.level = 5
@base_temp_directory_path = File.join(File.dirname(__FILE__), 'tmp')
end
config.before(:each) do
@entropy = Time.now.to_f.to_s
@@ -19,21 +23,13 @@
config.after(:each) do
FileUtils.rm_rf @base_temp_directory_path
end
end
-
-def decode_avro(schema_string, serialized_object)
+def decode_avro(schema_string, bytes)
schema = Avro::Schema.parse(schema_string)
- serialized_object.force_encoding 'BINARY'
- sio = StringIO.new(serialized_object)
- Avro::IO::DatumReader.new(schema, schema).read Avro::IO::BinaryDecoder.new(sio)
+ RFlow::Avro.decode(Avro::IO::DatumReader.new(schema, schema), bytes)
end
-def encode_avro(schema_string, object)
- encoded_string = ''
- encoded_string.force_encoding 'BINARY'
- schema = Avro::Schema.parse(schema_string)
- sio = StringIO.new(encoded_string)
- Avro::IO::DatumWriter.new(schema).write object, Avro::IO::BinaryEncoder.new(sio)
- encoded_string
+def encode_avro(schema_string, message)
+ RFlow::Avro.encode(Avro::IO::DatumWriter.new(Avro::Schema.parse(schema_string)), message)
end