Skip to content

Commit

Permalink
RUB-14 Fix translator specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish91 committed Oct 12, 2023
1 parent 5723d48 commit fc5f8b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/generators/language_classes_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 17 additions & 1 deletion spec/templates/translator/language_based_translator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc5f8b6

Please sign in to comment.