Sha256: 1708902f3f75002477bb1845f64154b33eba7fbfc071dfa319b09b817fab01f9
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require "test_helper" require "rails_translation_manager/yaml_writer" module RailsTranslationManager class DummyWriter include YAMLWriter end class WriterTest < Minitest::Test def setup @output_file = Tempfile.new('fr') end def teardown @output_file.close @output_file.unlink end test 'outputs YAML without the header --- line for consistency with convention' do data = {"fr" => { key1: [:source, :translation], "key2" => ["value", "le value"], }} DummyWriter.new.write_yaml(output_file, data) assert_equal "fr:", File.readlines(output_file).first.strip end test 'outputs a newline at the end of the YAML for consistency with code editors' do data = {"fr" => { key1: [:source, :translation], "key2" => ["value", "le value"], }} DummyWriter.new.write_yaml(output_file, data) assert_match (/\n$/), File.readlines(output_file).last end test 'strips whitespace from the end of lines for consistency with code editors' do data = {fr: { key1: [:source, :translation], "key2" => ["value", nil], }} DummyWriter.new.write_yaml(output_file, data) lines = File.readlines(output_file) refute lines.any? { |line| line =~ /\s\n$/ } end private def output_file @output_file.path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_translation_manager-1.8.0 | test/rails_translation_manager/yaml_writer_test.rb |