Skip to content

Commit

Permalink
Fix Ruby-head compatibility
Browse files Browse the repository at this point in the history
Replace OpenStruct with Struct to allow spec passing against ruby-head
without requiring openstruct in development dependencies
  • Loading branch information
tagliala committed Sep 15, 2024
1 parent 2cd5677 commit 133f161
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spec/render_jsonapi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def index

context 'when using a cache' do
controller do
User = Struct.new(:id, :name, :dob)

def serializer
Class.new(JSONAPI::Serializable::Resource) do
type 'users'
Expand All @@ -32,17 +34,17 @@ def jsonapi_cache_key(*)
end

def user
OpenStruct.new(id: 1, name: 'Johnny Cache', dob: Time.utc(2021,1,1))
User.new(id: 1, name: 'Johnny Cache', dob: Time.utc(2021,1,1))
end

def index
render jsonapi: [user],
class: { OpenStruct: serializer }
class: { User: serializer }
end

def index_with_caching
render jsonapi: [user],
class: { OpenStruct: serializer },
class: { User: serializer },
cache: Rails.cache
end
end
Expand Down

0 comments on commit 133f161

Please sign in to comment.