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

fix error when fixture has erb #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/oas_rails/spec/media_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include 'erb'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be require 'erb'. The tests failed because of it, apparently. And I am not sure if you need to require it here, Does not do it rails and zeitwerk?

module OasRails
module Spec
class MediaType
Expand Down Expand Up @@ -68,7 +69,11 @@ def fetch_factory_bot_examples(klass:)
def fetch_fixture_examples(klass:)
fixture_file = Rails.root.join('test', 'fixtures', "#{klass.to_s.pluralize.downcase}.yml")
begin
fixture_data = YAML.load_file(fixture_file).with_indifferent_access
erb_result = ERB.new(File.read(fixture_file)).result
fixture_data = YAML.safe_load(
erb_result,
permitted_classes: [Symbol, ActiveSupport::HashWithIndifferentAccess]
).with_indifferent_access
rescue Errno::ENOENT
return {}
end
Expand Down
Loading