Browse Source

Added unit test for PascalCasing package names in Ruby.

Josh Haberman 9 years ago
parent
commit
6d92233e72

+ 5 - 0
ruby/Rakefile

@@ -80,10 +80,15 @@ end
 
 
 # Proto for tests.
 # Proto for tests.
 genproto_output << "tests/generated_code.rb"
 genproto_output << "tests/generated_code.rb"
+genproto_output << "tests/test_import.rb"
 file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task|
 file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task|
   sh "../src/protoc --ruby_out=. tests/generated_code.proto"
   sh "../src/protoc --ruby_out=. tests/generated_code.proto"
 end
 end
 
 
+file "tests/test_import.rb" => "tests/test_import.proto" do |file_task|
+  sh "../src/protoc --ruby_out=. tests/test_import.proto"
+end
+
 task :genproto => genproto_output
 task :genproto => genproto_output
 
 
 task :clean do
 task :clean do

+ 1 - 1
ruby/tests/generated_code.proto

@@ -1,6 +1,6 @@
 syntax = "proto3";
 syntax = "proto3";
 
 
-package A.B.C;
+package a.b.c;
 
 
 message TestMessage {
 message TestMessage {
   int32 optional_int32 = 1;
   int32 optional_int32 = 1;

+ 2 - 0
ruby/tests/generated_code_test.rb

@@ -4,6 +4,7 @@
 $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
 $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
 
 
 require 'generated_code_pb'
 require 'generated_code_pb'
+require 'test_import_pb'
 require 'test/unit'
 require 'test/unit'
 
 
 class GeneratedCodeTest < Test::Unit::TestCase
 class GeneratedCodeTest < Test::Unit::TestCase
@@ -13,5 +14,6 @@ class GeneratedCodeTest < Test::Unit::TestCase
     # successfully creates message definitions and classes, not to test every
     # successfully creates message definitions and classes, not to test every
     # aspect of the extension (basic.rb is for that).
     # aspect of the extension (basic.rb is for that).
     m = A::B::C::TestMessage.new()
     m = A::B::C::TestMessage.new()
+    m2 = FooBar::TestImportedMessage.new()
   end
   end
 end
 end

+ 5 - 0
ruby/tests/test_import.proto

@@ -0,0 +1,5 @@
+syntax = "proto3";
+
+package foo_bar;
+
+message TestImportedMessage {}