zipmark/rspec_api_documentation

Docs generation fails if upload multiple files in a test case

Opened this issue · 2 comments

Error Messages

Coverage report generated for RSpec to /mnt/c/Users/b9990/Documents/GitHub/compassbioinfo/good_will_mina_api/coverage. 1125 / 1181 LOC (95.26
%) covered.
SimpleCov failed with exit 1
Traceback (most recent call last):
        45: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/exe/rspec:4:in `<main>'
        44: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:45:in `invoke'
        43: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:71:in `run'
        42: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:89:in `run'
        41: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:115:in `run_specs'
        40: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:76:in `report'
        39: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:174:in `finish'
        38: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:194:in `close_after'
        37: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:175:in `block in finish'
        36: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:202:in `stop'
        35: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:208:in `notify'
        34: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:208:in `each'
        33: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:209:in `block in notify'
        32: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/api_formatter.rb:38:in `stop
'
        31: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/api_formatter.rb:38:in `each
'
        30: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/api_documentation.rb:28:in `
write'
        29: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/api_documentation.rb:28:in `
each'
        28: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/api_documentation.rb:29:in `
block in write'
        27: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/writers/writer.rb:13:in `wri
te'
        26: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/writers/general_markup_write
r.rb:10:in `write'
        25: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/writers/general_markup_write
r.rb:10:in `open'
        24: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/writers/general_markup_write
r.rb:11:in `block in write'
        23: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache.rb:133:in `render'
        22: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:44:in `render'
        21: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:36472:in `render'
        20: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:36472:in `map'
        19: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:48671:in `block in render'
        18: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:48671:in `map'
        17: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:54277:in `block (2 levels) in render'
        16: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:54277:in `map'
        15: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:55376:in `block (3 levels) in render'
        14: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:55376:in `map'
        13: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/template.rb:55376:in `block (4 levels) in render'
        12: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:94:in `[]'
        11: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:112:in `fetch'
        10: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:112:in `each'
         9: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:116:in `block in fetch'
         8: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:148:in `find'
         7: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/mustache-1.1.1/lib/mustache/context.rb:148:in `call'
         6: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:22:in `requests'
         5: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:22:in `map'
         4: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:28:in `block in requests'
         3: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:74:in `indent'
         2: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:74:in `tap'
         1: from /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.
rb:76:in `block in indent'
/home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec_api_documentation-6.1.0/lib/rspec_api_documentation/views/api_blueprint_example.rb:76:in `gsub!':
 invalid byte sequence in UTF-8 (ArgumentError)
/home/khiav/.rvm/rubies/ruby-2.5.5/bin/ruby -I/home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/lib:/home/khiav/.rvm/gems/ruby-2.5.5/gem
s/rspec-support-3.9.2/lib /home/khiav/.rvm/gems/ruby-2.5.5/gems/rspec-core-3.9.1/exe/rspec --pattern spec/acceptance/\*\*/\*_spec.rb --format
 RspecApiDocumentation::ApiFormatter failed

The failed test case is:

parameter :photos, with_example: true, required: true

let(:green_png) { fixture_file_upload("files/green.png", "image/png") }
let(:photos) { [green_png, green_png] }

The problem may come from this line:
https://github.com/zipmark/rspec_api_documentation/blob/6.1.0/lib/rspec_api_documentation/client_base.rb#L102

I get empty string when it try to read the tempfile.

@khiav223577 have you solved the issue

@khiav223577 have you solved the issue

I have a workaround but it have to modified the source code.

I changed this line:

-request_body.gsub(data, "[uploaded data]")
+data == '' ? request_body : request_body.gsub(data, "[uploaded data]")