THRIFT = '../../compiler/cpp/thrift'
-task :default => [:spec, :test]
+task :default => [:'gen-rb', :spec, :test]
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
SETS => {:type => Thrift::Types::LIST, :name => 'sets', :element => {:type => Thrift::Types::SET, :element => {:type => Thrift::Types::I16}}},
HELLOS => {:type => Thrift::Types::LIST, :name => 'hellos', :element => {:type => Thrift::Types::STRUCT, :class => Hello}}
}
+ def validate
+ end
+
+ end
+
+ class Xception < Thrift::Exception
+ include Thrift::Struct
+ MESSAGE = 1
+ CODE = 2
+
+ Thrift::Struct.field_accessor self, :message, :code
+ FIELDS = {
+ MESSAGE => {:type => Thrift::Types::STRING, :name => 'message'},
+ CODE => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
+ }
+ def validate
+ end
+
end
end
include Thrift
include SpecNamespace
- class Xception < Thrift::Exception
- include Thrift::Struct
- attr_accessor :message, :code
- FIELDS = {
- 1 => {:type => Thrift::Types::STRING, :name => 'message'},
- 2 => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
- }
- end
-
describe Struct do
it "should iterate over all fields properly" do
fields = {}
e.code.should == 1
# ensure it gets serialized properly, this is the really important part
prot = mock("Protocol")
- prot.should_receive(:write_struct_begin).with("ThriftStructSpec::Xception")
+ prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field).with('message', Types::STRING, 1, "something happened")
prot.should_receive(:write_field).with('code', Types::I32, 2, 1)
e.message.should == "something happened"
e.code.should == 5
prot = mock("Protocol")
- prot.should_receive(:write_struct_begin).with("ThriftStructSpec::Xception")
+ prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field).with('message', Types::STRING, 1, "something happened")
prot.should_receive(:write_field).with('code', Types::I32, 2, 5)