|
26 | 26 | it 'should show a hash presentation of an entry' do |
27 | 27 | @entry.msgid = 'string' |
28 | 28 | @entry.msgstr = 'reshte' |
29 | | - @entry.translator_comment = ['comment', 'second line of comments'] |
30 | | - result = { |
31 | | - :translator_comment => ['comment', 'second line of comments'], |
32 | | - :msgid => 'string', |
33 | | - :msgstr => 'reshte' |
34 | | - } |
35 | | - expect(@entry.to_h).to eq(result) |
| 29 | + expect(@entry.to_h).to eq({:msgid=>"string", :msgstr=>"reshte"}) |
36 | 30 | end |
37 | 31 |
|
38 | | - it 'should show a hash presentation of a plural string entry' do |
39 | | - @entry = PoParser::Entry.new |
40 | | - @entry.msgid_plural = 'right word' |
41 | | - @entry.msgstr_0 = %w[mot juste] |
42 | | - @entry.msgstr_1 = %w[mots justes] |
43 | | - @entry.translator_comment = ['comment', 'second line of comments'] |
44 | | - |
45 | | - result = { |
46 | | - :translator_comment => ['comment', 'second line of comments'], |
47 | | - :msgid_plural => 'right word', |
48 | | - :'msgstr[0]' => %w[mot juste], |
49 | | - :'msgstr[1]' => %w[mots justes] |
| 32 | + it 'should show a hash representation of a complex entry' do |
| 33 | + # Ensure the to_h method is reversible |
| 34 | + # From SimplePoParser::Parser - https://github.com/experteer/simple_po_parser/blob/v1.1.5/spec/simple_po_parser/parser_spec.rb#L31 |
| 35 | + entry_hash = { |
| 36 | + :translator_comment => ["translator-comment", ""], |
| 37 | + :extracted_comment => "extract", |
| 38 | + :reference => ["reference1", "reference2"], |
| 39 | + :flag => "flag", |
| 40 | + :previous_msgctxt => "previous context", |
| 41 | + :previous_msgid => ["", "multiline\\n", "previous messageid"], |
| 42 | + :previous_msgid_plural => "previous msgid_plural", |
| 43 | + :msgctxt => "Context", |
| 44 | + :msgid => "msgid", |
| 45 | + :msgid_plural => ["", "multiline msgid_plural\\n", ""], |
| 46 | + "msgstr[0]" => "msgstr 0", |
| 47 | + "msgstr[1]" => ["", "msgstr 1 multiline 1\\n", "msgstr 1 line 2\\n"], |
| 48 | + "msgstr[2]" => "msgstr 2" |
50 | 49 | } |
51 | | - expect(@entry.to_h).to eq(result) |
| 50 | + |
| 51 | + entry = PoParser::Entry.new(entry_hash) |
| 52 | + expect(entry.to_h).to eq(entry_hash) |
52 | 53 | end |
53 | 54 |
|
54 | 55 | it 'should translate the entry' do |
|
0 commit comments