diff --git a/spec/generators/language_classes_generator_spec.rb b/spec/generators/language_classes_generator_spec.rb index 2df7581..5b71b3f 100644 --- a/spec/generators/language_classes_generator_spec.rb +++ b/spec/generators/language_classes_generator_spec.rb @@ -15,7 +15,7 @@ it "generates translation files for ruby classes" do subject.generate_class_files - ['array.yml'].each do |file| + ['array.yml', 'class.yml', 'integer.yml', 'math.yml', 'module.yml', 'object.yml'].each do |file| generated = YAML.load_file(Dir.pwd + '/spec/stubs/gem_path/lib/translations/classes/' + file) orig = YAML.load_file(Dir.pwd + '/spec/stubs/language_classes_generator/' + file) diff --git a/spec/templates/translator/language_based_translator_spec.rb b/spec/templates/translator/language_based_translator_spec.rb index 394a22f..6b1c5fc 100644 --- a/spec/templates/translator/language_based_translator_spec.rb +++ b/spec/templates/translator/language_based_translator_spec.rb @@ -21,7 +21,23 @@ translated_class_path = Dir.pwd + "/spec/stubs/translated/classes/#{filename}" - expect(FileUtils.compare_file(translated_class_path, target_class_path)).to be_truthy + compare_translations(translated_class_path, target_class_path, filename) + end + end + end + + def compare_translations(orig, generated, filename) + orig = YAML.load_file(orig) + generated = YAML.load_file(generated) + + klass = filename.split('.')[0] + expect(generated[klass]['cname']).to eq(orig[klass]['cname']) + + orig[klass].keys.each do |method_type| + next if method_type == 'cname' + + orig[klass][method_type].keys do |method| + expect(generated[klass][method_type][method]).to eq(orig[klass][method_type][method]) end end end