Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test code not working, OpenOffice jumbled #14

Closed
cboe opened this issue Apr 9, 2015 · 14 comments
Closed

Test code not working, OpenOffice jumbled #14

cboe opened this issue Apr 9, 2015 · 14 comments

Comments

@cboe
Copy link

cboe commented Apr 9, 2015

I've tried using Sablon in my own code with the same code used in the test example and the provided docx template, however, none of the contents seem to be replaced by sablon. Here is the code:

template = Sablon.template(File.expand_path(Rails.root.join('doc', 'translation-template.docx')))
person = OpenStruct.new "first_name" => "Ronald", "last_name" => "Anderson", "address" => {"street" => "Panda Bay 4A"}
item = Struct.new(:index, :label, :rating)
position = Struct.new(:duration, :label, :description)
language = Struct.new(:name, :skill)
context = {
  current_time: Time.now.strftime("%d.%m.%Y %H:%M"),
  author: "Yves Senn",
  title: "Letter of application",
  person: person,
  about_me: "asdf",
  items: [item.new("1.", "Ruby", "★" * 5), item.new("2.", "Java", "★" * 1), item.new("3.", "Python", "★" * 3)],
  career: [position.new("1999 - 2006", "Junior Java Engineer", "Lorem ipsum dolor\nsit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."),
           position.new("2006 - 2013", "Senior Ruby Developer", "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo."),
           position.new("2013 - today", "Sales...", nil)],
  technologies: ["HTML", "CSS", "SASS", "LESS", "JavaScript"],
  languages: [language.new("German", "native speaker"), language.new("English", "fluent")],
  training: "At vero eos et accusam et justo duo dolores et ea rebum.\n\nStet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
}
template.render_to_file File.expand_path("~/Desktop/output.docx"), context

all I've changed is the filename, the about_me content and removed the page properties. In addition, opening the output document in OpenOffice 4.0.1, the document is all over the place, see picture of first page.

Specs:

OSX 10.9.5
ruby-2.1.0, rails 3.2.21
added sablon through gemfile like this
gem 'sablon', :git => "https://github.com/senny/sablon.git"
doing it without git yielded the same results

screen shot 2015-04-09 at 18 15 02

@senny
Copy link
Owner

senny commented Apr 9, 2015

@cboe are the tests passing on your machine?

$ cd <path to sablon>
$ bundle
$ bundle exec rake

@senny
Copy link
Owner

senny commented Apr 10, 2015

@cboe There is a sample file checked into the repository. This file is used to compare generated files and make sure they are identical. You can find it here.

Up to this point sablon was developed with only Microsoft Word in mind. I've downloaded OpenOffice and when I open the sample files they do look hugely distorted. I'm guessing there is something wrong in the XML-structure that Word happily ignores:

screen shot 2015-04-10 at 09 28 47

As the README states, this is very much in early development and focused on the use-cases I've encountered so far. If you'd like to use sablon with OpenOffice I expect you'd have to submit some patches to get it to work accordingly. I'm very open to pull requests if you decide to go that path. I can't guarantee that I'll have the time to make it work with OpenOffice in the near future.

@senny
Copy link
Owner

senny commented Apr 10, 2015

Opening and Saving the generated documents with Microsoft Word makes the generated files work with Open Office. It could be non-significant whitespace that I generate into the document.xml or Word restructures the XML on save. This should be a good starting point to investigate the issue.

Following is a screenshot of the same document as above but with a open/save roundtrip through MS Word:

screen shot 2015-04-10 at 09 38 25

@senny
Copy link
Owner

senny commented Apr 10, 2015

@cboe I pushed a commit addressing the whitespace issue with Open Office. This solves the jumbled look of generated documents opened with Open Office (at least on my machine). However, this does not change the fact that your rendered document still contains the placeholders.

@cboe
Copy link
Author

cboe commented Apr 10, 2015

Thanks for that, it looks right in Open Office now! I have problems running the tests, I'll try again later. BTW, does the gem support chinese characters?

@senny
Copy link
Owner

senny commented Apr 10, 2015

@cboe I have no idea 😁 I'n theory it should work with any unicode character.

@cboe
Copy link
Author

cboe commented Apr 12, 2015

well here are some of the results from the tests

christophs-mbp:sablon-3d38b9668dc5 cboe$ ruby -I ./test test/processor_test.rb
Run options: --seed 35646

Running:

FFFFFFFFFEFFFFFFF

Finished in 0.204225s, 83.2415 runs/s, 78.3450 assertions/s.

  1. Failure:
    ProcessorTest#test_paragraph_block_replacement [test/processor_test.rb:65]:
    --- expected
    +++ actual
    @@ -1 +1 @@
    -"Ruby Rails"
    +"«technologies:each(technology)» MERGEFIELD =technology \* MERGEFORMAT «=technology» «technologies:endEach»"

  2. Failure:
    ProcessorTest#test_simple_field_replacement [test/processor_test.rb:18]:
    --- expected
    +++ actual
    @@ -1 +1 @@
    -"Hello! My Name is Jack , nice to meet you."
    +"Hello! My Name is «=first_name» , nice to meet you."

  3. Failure:
    ProcessorTest#test_loop_with_missing_variable_raises_error [test/processor_test.rb:301]:
    Sablon::ContextError expected but nothing was raised.

  4. Failure:
    ProcessorTest#test_complex_field_replacement [test/processor_test.rb:37]:
    --- expected
    +++ actual
    @@ -1 +1 @@
    -"Hello! My Name is Zane , nice to meet you."
    +"Hello! My Name is MERGEFIELD =last_name \* MERGEFORMAT «=last_name» , nice to meet you."

  5. Failure:
    ProcessorTest#test_single_row_table_loop [test/processor_test.rb:195]:
    --- expected
    +++ actual
    @@ -65,7 +65,7 @@
    "tr": [
    {
    "w:rsidR": "00757DAD",

  •          \"w14:paraId\": \"1BD2E50A\",
    
  •          \"w14:paraId\": \"229B7A39\",
           \"w14:textId\": \"77777777\",
           \"w:rsidTr\": \"006333C3\",
           \"tc\": [
    

    @@ -82,13 +82,35 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"41ACB3D9\",
    
  •                  \"w14:paraId\": \"3D472BF1\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
                   \"w:rsidP\": \"006333C3\",
                   \"r\": [
                     {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"begin\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"instrText\": [
    
  •                        {
    
  •                          \"xml:space\": \"preserve\",
    
  •                          \"content\": \" MERGEFIELD items:each(item) \\\* MERGEFORMAT \"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"separate\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
                       \"rPr\": [
                         {
                           \"noProof\": [
    

    @@ -98,7 +120,14 @@
    }
    ],
    "t": [

  •                        \"1.\"
    
  •                        \"«items:each(item)»\"
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"end\"
    
  •                        }
                       ]
                     }
                   ]
    

    @@ -118,13 +147,85 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"197C6F31\",
    
  •                  \"w14:paraId\": \"6E6D8DB2\",
    
  •                  \"w14:textId\": \"77777777\",
    
  •                  \"w:rsidR\": \"00757DAD\",
    
  •                  \"w:rsidRDefault\": \"00757DAD\",
    
  •                  \"w:rsidP\": \"006333C3\"
    
  •                }
    
  •              ]
    
  •            },
    
  •            {
    
  •              \"tcPr\": [
    
  •                {
    
  •                  \"tcW\": [
    
  •                    {
    
  •                      \"w:w\": \"2029\",
    
  •                      \"w:type\": \"dxa\"
    
  •                    }
    
  •                  ]
    
  •                }
    
  •              ],
    
  •              \"p\": [
    
  •                {
    
  •                  \"w14:paraId\": \"7BE1DB00\",
    
  •                  \"w14:textId\": \"77777777\",
    
  •                  \"w:rsidR\": \"00757DAD\",
    
  •                  \"w:rsidRDefault\": \"00757DAD\",
    
  •                  \"w:rsidP\": \"006333C3\"
    
  •                }
    
  •              ]
    
  •            }
    
  •          ]
    
  •        },
    
  •        {
    
  •          \"w:rsidR\": \"00757DAD\",
    
  •          \"w14:paraId\": \"1BD2E50A\",
    
  •          \"w14:textId\": \"77777777\",
    
  •          \"w:rsidTr\": \"006333C3\",
    
  •          \"tc\": [
    
  •            {
    
  •              \"tcPr\": [
    
  •                {
    
  •                  \"tcW\": [
    
  •                    {
    
  •                      \"w:w\": \"2202\",
    
  •                      \"w:type\": \"dxa\"
    
  •                    }
    
  •                  ]
    
  •                }
    
  •              ],
    
  •              \"p\": [
    
  •                {
    
  •                  \"w14:paraId\": \"41ACB3D9\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
                   \"w:rsidP\": \"006333C3\",
                   \"r\": [
                     {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"begin\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"instrText\": [
    
  •                        {
    
  •                          \"xml:space\": \"preserve\",
    
  •                          \"content\": \" MERGEFIELD =item.index \\\* MERGEFORMAT \"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"separate\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
                       \"rPr\": [
                         {
                           \"noProof\": [
    

    @@ -134,7 +235,14 @@
    }
    ],
    "t": [

  •                        \"Milk\"
    
  •                        \"«=item.index»\"
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"end\"
    
  •                        }
                       ]
                     }
                   ]
    

    @@ -146,7 +254,7 @@
    {
    "tcW": [
    {

  •                      \"w:w\": \"2029\",
    
  •                      \"w:w\": \"4285\",
                       \"w:type\": \"dxa\"
                     }
                   ]
    

    @@ -154,13 +262,35 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"55C258BB\",
    
  •                  \"w14:paraId\": \"197C6F31\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
                   \"w:rsidP\": \"006333C3\",
                   \"r\": [
                     {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"begin\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"instrText\": [
    
  •                        {
    
  •                          \"xml:space\": \"preserve\",
    
  •                          \"content\": \" MERGEFIELD =item.label \\\* MERGEFORMAT \"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"separate\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
                       \"rPr\": [
                         {
                           \"noProof\": [
    

    @@ -170,27 +300,26 @@
    }
    ],
    "t": [

  •                        \"***\"
    
  •                        \"«=item.label»\"
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"end\"
    
  •                        }
                       ]
                     }
                   ]
                 }
               ]
    
  •            }
    
  •          ]
    
  •        },
    
  •        {
    
  •          \"w:rsidR\": \"00757DAD\",
    
  •          \"w14:paraId\": \"1BD2E50A\",
    
  •          \"w14:textId\": \"77777777\",
    
  •          \"w:rsidTr\": \"006333C3\",
    
  •          \"tc\": [
    
  •            },
             {
               \"tcPr\": [
                 {
                   \"tcW\": [
                     {
    
  •                      \"w:w\": \"2202\",
    
  •                      \"w:w\": \"2029\",
                       \"w:type\": \"dxa\"
                     }
                   ]
    

    @@ -198,13 +327,35 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"41ACB3D9\",
    
  •                  \"w14:paraId\": \"55C258BB\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
                   \"w:rsidP\": \"006333C3\",
                   \"r\": [
                     {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"begin\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"instrText\": [
    
  •                        {
    
  •                          \"xml:space\": \"preserve\",
    
  •                          \"content\": \" MERGEFIELD =item.rating \\\* MERGEFORMAT \"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"separate\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
                       \"rPr\": [
                         {
                           \"noProof\": [
    

    @@ -214,19 +365,34 @@
    }
    ],
    "t": [

  •                        \"2.\"
    
  •                        \"«=item.rating»\"
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"end\"
    
  •                        }
                       ]
                     }
                   ]
                 }
               ]
    
  •            },
    
  •            }
    
  •          ]
    
  •        },
    
  •        {
    
  •          \"w:rsidR\": \"00757DAD\",
    
  •          \"w14:paraId\": \"2D3C09BC\",
    
  •          \"w14:textId\": \"77777777\",
    
  •          \"w:rsidTr\": \"006333C3\",
    
  •          \"tc\": [
             {
               \"tcPr\": [
                 {
                   \"tcW\": [
                     {
    
  •                      \"w:w\": \"4285\",
    
  •                      \"w:w\": \"2202\",
                       \"w:type\": \"dxa\"
                     }
                   ]
    

    @@ -234,13 +400,35 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"197C6F31\",
    
  •                  \"w14:paraId\": \"04A961B7\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
                   \"w:rsidP\": \"006333C3\",
                   \"r\": [
                     {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"begin\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"instrText\": [
    
  •                        {
    
  •                          \"xml:space\": \"preserve\",
    
  •                          \"content\": \" MERGEFIELD items:endEach \\\* MERGEFORMAT \"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"separate\"
    
  •                        }
    
  •                      ]
    
  •                    },
    
  •                    {
                       \"rPr\": [
                         {
                           \"noProof\": [
    

    @@ -250,7 +438,14 @@
    }
    ],
    "t": [

  •                        \"Sugar\"
    
  •                        \"«items:endEach»\"
    
  •                      ]
    
  •                    },
    
  •                    {
    
  •                      \"fldChar\": [
    
  •                        {
    
  •                          \"w:fldCharType\": \"end\"
    
  •                        }
                       ]
                     }
                   ]
    

    @@ -262,7 +457,7 @@
    {
    "tcW": [
    {

  •                      \"w:w\": \"2029\",
    
  •                      \"w:w\": \"4285\",
                       \"w:type\": \"dxa\"
                     }
                   ]
    

    @@ -270,27 +465,33 @@
    ],
    "p": [
    {

  •                  \"w14:paraId\": \"55C258BB\",
    
  •                  \"w14:paraId\": \"71165BFB\",
                   \"w14:textId\": \"77777777\",
                   \"w:rsidR\": \"00757DAD\",
                   \"w:rsidRDefault\": \"00757DAD\",
    
  •                  \"w:rsidP\": \"006333C3\",
    
  •                  \"r\": [
    
  •                  \"w:rsidP\": \"006333C3\"
    
  •                }
    
  •              ]
    
  •            },
    
  •            {
    
  •              \"tcPr\": [
    
  •                {
    
  •                  \"tcW\": [
                     {
    
  •                      \"rPr\": [
    
  •                        {
    
  •                          \"noProof\": [
    
  •                            {
    
  •                            }
    
  •                          ]
    
  •                        }
    
  •                      ],
    
  •                      \"t\": [
    
  •                        \"**\"
    
  •                      ]
    
  •                      \"w:w\": \"2029\",
    
  •                      \"w:type\": \"dxa\"
                     }
                   ]
                 }
    
  •              ],
    
  •              \"p\": [
    
  •                {
    
  •                  \"w14:paraId\": \"01D3965C\",
    
  •                  \"w14:textId\": \"77777777\",
    
  •                  \"w:rsidR\": \"00757DAD\",
    
  •                  \"w:rsidRDefault\": \"00757DAD\",
    
  •                  \"w:rsidP\": \"006333C3\"
    
  •                }
               ]
             }
           ]
    
    1. Failure:
      ProcessorTest#test_paragraph_block_within_table_cell [test/processor_test.rb:98]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"Puppet Chef"
      +"«technologies:each(technology)» «=technology» «technologies:endEach»"

    2. Failure:
      ProcessorTest#test_multi_row_table_loop [test/processor_test.rb:327]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"1. Milk Milk is a white liquid. 2. Sugar Sugar is the generalized name for carbohydrates."
      +"«foods:each(food)» «=food.index» MERGEFIELD = food .label \* MERGEFORMAT «=food.label» «=food.body» MERGEFIELD foods:endEach \* MERGEFORMAT «foods:endEach»"

    3. Failure:
      ProcessorTest#test_complex_field_replacement_with_split_field [test/processor_test.rb:51]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"Hello! My Name is Daniel , nice to meet you."
      +"Hello! My Name is MERGEFIELD = first_name \* MERGEFORMAT «=person.first_name» , nice to meet you."

    4. Failure:
      ProcessorTest#test_loop_with_missing_end_raises_error [test/processor_test.rb:308]:
      Sablon::TemplateError expected but nothing was raised.

    5. Error:
      ProcessorTest#test_adds_blank_paragraph_to_empty_table_cells:
      REXML::UndefinedNamespaceException: Undefined prefix w:w found
      /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:413:in block in pull_event' /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/set.rb:263:ineach_key'
      /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/set.rb:263:in each' /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:411:inpull_event'
      /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:184:in pull' /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/parsers/treeparser.rb:22:inparse'
      /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/document.rb:283:in build' /Users/cboe/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rexml/document.rb:44:ininitialize'
      /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/xml-simple-1.1.5/lib/xmlsimple.rb:971:in new' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/xml-simple-1.1.5/lib/xmlsimple.rb:971:inparse'
      /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/xml-simple-1.1.5/lib/xmlsimple.rb:164:in xml_in' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/xml-simple-1.1.5/lib/xmlsimple.rb:203:inxml_in'
      /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/test/support/document_xml_helper.rb:8:in assert_xml_equal' test/processor_test.rb:144:intest_adds_blank_paragraph_to_empty_table_cells'

    6. Failure:
      ProcessorTest#test_conditional_with_missing_end_raises_error [test/processor_test.rb:315]:
      Sablon::TemplateError expected but nothing was raised.

    7. Failure:
      ProcessorTest#test_context_can_contain_string_and_symbol_keys [test/processor_test.rb:31]:
      Expected: "Jack Davis"
      Actual: "«=first_name» «=last_name»"

    8. Failure:
      ProcessorTest#test_conditional_with_predicate [test/processor_test.rb:340]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"some content"
      +"«body:if(empty?)» some content «body:endIf»"

    9. Failure:
      ProcessorTest#test_loop_over_collection_convertable_to_an_enumerable [test/processor_test.rb:289]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"CSS SCSS LESS"
      +"«technologies:each(technology)» MERGEFIELD =technology \* MERGEFORMAT «=technology» «technologies:endEach»"

    10. Failure:
      ProcessorTest#test_paragraph_block_within_empty_table_cell_and_blank_replacement [test/processor_test.rb:127]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -""
      +"«technologies:each(technology)» «=technology» «technologies:endEach»"

    11. Failure:
      ProcessorTest#test_conditional [test/processor_test.rb:332]:
      --- expected
      +++ actual
      @@ -1 +1 @@
      -"Anthony Michael Hall"
      +"Anthony «middle_name:if» «=middle_name» «middle_name:endIf» Hall"

    12. Failure:
      ProcessorTest#test_loop_over_collection_not_convertable_to_an_enumerable_raises_error [test/processor_test.rb:295]:
      Sablon::ContextError expected but nothing was raised.

17 runs, 16 assertions, 16 failures, 1 errors, 0 skips

@cboe
Copy link
Author

cboe commented Apr 12, 2015

christophs-mbp:sablon-3d38b9668dc5 cboe$ ruby -I ./test test/sablon_test.rb
Run options: --seed 32993

Running:

E

Finished in 0.024424s, 40.9433 runs/s, 0.0000 assertions/s.

  1. Error:
    SablonTest#test_generate_document_from_template:
    TypeError: no implicit conversion of Fixnum into String
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/processor/section_properties.rb:17:in []=' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/processor/section_properties.rb:17:instart_page_number='
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/processor.rb:31:in write_properties' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/processor.rb:7:inprocess'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:43:in process' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:27:inblock (2 levels) in render'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/entry_set.rb:42:in call' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/entry_set.rb:42:inblock in each'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/entry_set.rb:41:in each' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/entry_set.rb:41:ineach'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/central_directory.rb:182:in each' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:22:inblock in render'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/gems/rubyzip-1.1.4/lib/zip/output_stream.rb:60:in write_buffer' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:21:inrender'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:16:in render_to_string' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:10:inblock in render_to_file'
    /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:9:in open' /Users/cboe/.rvm/gems/ruby-2.1.0@porsche.dmgmori.com/bundler/gems/sablon-3d38b9668dc5/lib/sablon/template.rb:9:inrender_to_file'
    test/sablon_test.rb:38:in `test_generate_document_from_template'

1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
zlib(finalizer): the stream was freed prematurely.

@cboe
Copy link
Author

cboe commented Apr 12, 2015

christophs-mbp:sablon-3d38b9668dc5 cboe$ ruby -I ./test test/section_properties_test.rb
Run options: --seed 58810

Running:

FF

Finished in 0.004225s, 473.3728 runs/s, 710.0592 assertions/s.

  1. Failure:
    SectionPropertiesTest#test_assign_start_page_number_without_pgNumType_tag [test/section_properties_test.rb:39]:
    Expected: "16"
    Actual: nil

  2. Failure:
    SectionPropertiesTest#test_assign_start_page_number_with_pgNumType_tag [test/section_properties_test.rb:20]:
    Expected: "1"
    Actual: nil

2 runs, 3 assertions, 2 failures, 0 errors, 0 skips

@cboe
Copy link
Author

cboe commented Apr 12, 2015

christophs-mbp:sablon-3d38b9668dc5 cboe$ ruby -I ./test test/section_properties_test.rb
Run options: --seed 58810

Running:

FF

Finished in 0.004225s, 473.3728 runs/s, 710.0592 assertions/s.

  1. Failure:
    SectionPropertiesTest#test_assign_start_page_number_without_pgNumType_tag [test/section_properties_test.rb:39]:
    Expected: "16"
    Actual: nil

  2. Failure:
    SectionPropertiesTest#test_assign_start_page_number_with_pgNumType_tag [test/section_properties_test.rb:20]:
    Expected: "1"
    Actual: nil

2 runs, 3 assertions, 2 failures, 0 errors, 0 skips
christophs-mbp:sablon-3d38b9668dc5 cboe$ ruby -I ./test test/mail_merge_parser_test.rb
Run options: --seed 8557

Running:

FE.FFE

Finished in 0.005531s, 1084.7948 runs/s, 723.1965 assertions/s.

  1. Failure:
    MailMergeParser::FldCharTest#test_recognizes_expression [test/mail_merge_parser_test.rb:67]:
    Expected: ["=last_name"]
    Actual: []

  2. Error:
    MailMergeParser::FldCharTest#test_replace:
    NoMethodError: undefined method replace' for nil:NilClass test/mail_merge_parser_test.rb:71:intest_replace'

  3. Failure:
    MailMergeParser::FieldWithWhitespaceTest#test_recognizes_expression [test/mail_merge_parser_test.rb:176]:
    Expected: ["=title"]
    Actual: []

  4. Failure:
    MailMergeParser::FldSimpleTest#test_recognizes_expression [test/mail_merge_parser_test.rb:34]:
    Expected: ["=first_name"]
    Actual: []

  5. Error:
    MailMergeParser::FldSimpleTest#test_replace:
    NoMethodError: undefined method replace' for nil:NilClass test/mail_merge_parser_test.rb:38:intest_replace'

6 runs, 4 assertions, 3 failures, 2 errors, 0 skips

@senny
Copy link
Owner

senny commented Apr 13, 2015

@cboe thank you for the output. You can run all tests together by executing bundle exec rake.

I see that the test already fail with test/mail_merge_parser_test.rb. This is the part that parses the sablon fields in the source template. If those fields are not recognized it's clear that the rest of the tests are failing as well.

I'll try to figure out what the cause could be but without a way for me to reproduce the errors it's going to be difficult.

@senny
Copy link
Owner

senny commented Apr 13, 2015

@cboe The errors could be related to the version of nokogiri and libxml2 you are using. Would you mind providing the following information:

$ cd <path to sablon repo>
$ cat Gemfile.lock
$ cd <path to sablon repo>
$ bundle exec irb
irb(main):002:0> require 'nokogiri'
=> true
irb(main):003:0> Nokogiri::VersionInfo.instance.loaded_parser_version
=> "2.9.2"
irb(main):004:0> Nokogiri::VersionInfo.instance.compiled_parser_version
=> "2.9.2"

Did you use system libraries when installing nokogiri?

@cboe
Copy link
Author

cboe commented Apr 13, 2015

Well that solved that, I had nokogiri v. 1.4.3.1 installed... thank you so much for your quick help!

@cboe cboe closed this as completed Apr 13, 2015
@senny
Copy link
Owner

senny commented Apr 13, 2015

@cboe thank you for confirming. I added a version requirement for nokogiri to make sure this doesn't happen to other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants