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

Changes Application#recorded_examples to better respect SafeYAML #207

Merged
merged 1 commit into from
Feb 21, 2014
Merged

Changes Application#recorded_examples to better respect SafeYAML #207

merged 1 commit into from
Feb 21, 2014

Conversation

pivotalshiny
Copy link
Contributor

It's possible for SafeYAML to be defined, but without having done the method patching in default YAML. This change tightens the check for SafeYAML to ensure that the correct api is used.

@iNecas
Copy link
Member

iNecas commented Feb 21, 2014

Does that mean, that without this check, it will start failing in this case?

@leschenko
Copy link
Contributor

It fails when safe_yaml is not required explicitly (in my case as a dependency of webmock gem)

.../ruby-2.1.0/lib/ruby/2.1.0/psych.rb:462:in `load_file': wrong number of arguments (2 for 1) (ArgumentError)
    from .../gems/apipie-rails-c82bd58df421/lib/apipie/application.rb:212:in `recorded_examples'

Some strange debugging staff (constant exists but load_file is not overridden):

   211          if defined? SafeYAML
   212            debugger
=> 213            @recorded_examples = YAML.load_file(tape_file, :safe=>false)
   214          else
   215            @recorded_examples = YAML.load_file(tape_file)
   216          end
   217        else
(rdb:1) defined? SafeYAML
"constant"
(rdb:1) YAML.load_file(tape_file, :safe=>false)
*** ArgumentError Exception: wrong number of arguments (2 for 1)

@iNecas
Copy link
Member

iNecas commented Feb 21, 2014

Thanks for explanation. Merging now.

iNecas added a commit that referenced this pull request Feb 21, 2014
Changes Application#recorded_examples to better respect SafeYAML
@iNecas iNecas merged commit 202474e into Apipie:master Feb 21, 2014
@iNecas
Copy link
Member

iNecas commented Mar 3, 2014

Released in 0.1.0. Thank you for your help!

@pivotalshiny
Copy link
Contributor Author

Thank you for merging it in promptly!

@iNecas
Copy link
Member

iNecas commented Mar 13, 2014

There was a regressions when using the SafeYAML loaded into YAML. #224 should fix this

@seku
Copy link

seku commented Apr 29, 2014

I have:
apipie-rails (0.1.3)
safe_yaml as a webmock dependency
and do experience exactly the same problem as @leschenko
The code fails on line:
https://github.com/Apipie/apipie-rails/blob/master/lib/apipie/extractor/writer.rb#L105
Any solutions ??

@iNecas
Copy link
Member

iNecas commented Apr 29, 2014

This is the version of loading yaml that should work https://github.com/Apipie/apipie-rails/blob/master/lib/apipie/application.rb#L213, anyway, I'm working on getting #130 finally out, so that the next release should not have to deal with the yaml loading at all

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

Successfully merging this pull request may close these issues.

4 participants