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

Unreadable examples.yml #125

Closed
johanneswuerbach opened this issue May 31, 2013 · 4 comments
Closed

Unreadable examples.yml #125

johanneswuerbach opened this issue May 31, 2013 · 4 comments

Comments

@johanneswuerbach
Copy link
Contributor

I generating the examples using:

APIPIE_RECORD=examples bundle exec rspec --order default

Sometimes this produces an unloadable yaml file. If I try to load the file manually it says

undefined method `first' for nil:NilClass
@johanneswuerbach
Copy link
Contributor Author

2013-05-31T04:05:15.419125+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:285:in `encode': "\xEF" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:285:in `generate'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:285:in `pretty_generate'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:165:in `format_example_data'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:174:in `format_example'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:159:in `block in load_recorded_examples'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:159:in `map'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:159:in `load_recorded_examples'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/method_description.rb:42:in `initialize'
2013-05-31T04:05:15.419125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/application.rb:46:in `new'
2013-05-31T04:05:15.419456+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/application.rb:46:in `block in define_method_description'
2013-05-31T04:05:15.419456+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/application.rb:38:in `each'
2013-05-31T04:05:15.419456+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/application.rb:38:in `define_method_description'
2013-05-31T04:05:15.419456+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/apipie_module.rb:18:in `method_missing'
2013-05-31T04:05:15.419456+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-eb1b6d3a2da3/lib/apipie/dsl_definition.rb:305:in `method_added'

Another unreadable record.

@johanneswuerbach
Copy link
Contributor Author

After disabling code coverage for APIPIE_RECORD rspec the yml file looks fine. We have some tests covering binary & base64 uploads, after disabling them the file is parseable again.

Our CI system is now trying to load and stringify the examples file before every deploy, so an invalid file can't break the server anymore.

JSON.pretty_generate(YAML.load_file("doc/apipie_examples.yml"))

@Pajk what do you think of changing the overall file format to json instead of serializing a hash to yml, to parse it and serialize to json again?

@iNecas
Copy link
Member

iNecas commented Jun 10, 2013

I remember a discussion about breaking the examples into smaller files, structured by controllers and actions (man I can't find it now :(, This was the first cat of the format, we have now much more input on how this could be improved.

Moving to json seems like a way to go.

johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Jun 16, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 8, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Oct 30, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Nov 22, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Nov 22, 2013
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Mar 3, 2014
johanneswuerbach added a commit to johanneswuerbach/apipie-rails that referenced this issue Mar 4, 2014
@kikonen-fiksu
Copy link

I've been hitting this error for a long time at

ruby-1.9.3-p484/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:124:in `block in visit_Psych_Nodes_Sequence': undefined method `first' for nil:NilClass (NoMethodError)
    from ruby-1.9.3-p484/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:123:in `each'

Causing re-generation of examples to fail (until old file is removed) and of course also display fails. And this seems to happen in random manner.

I quickly tested this "json-record" branch, and it seemed to fix issue. So is this fix going to get merged to master someday?

@iNecas iNecas closed this as completed in 6cb6692 Apr 30, 2014
iNecas added a commit that referenced this issue Apr 30, 2014
liorsion added a commit to liorsion/apipie-rails that referenced this issue May 8, 2014
* https://github.com/Apipie/apipie-rails:
  Test against ruby 2.1.1
  [Fixes Apipie#125] Dump examples as json
  Update initializer.rb.erb
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

3 participants