From 5be9bba478ab1bff500a5417e8d078106f598a4f Mon Sep 17 00:00:00 2001 From: Feng Ce Date: Mon, 6 May 2024 14:54:42 +0800 Subject: [PATCH] Add changelog and rspec --- CHANGELOG.md | 2 +- spec/grape_entity/entity_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d01b1..8135ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ #### Fixes * Your contribution here. - +* [#384](https://github.com/ruby-grape/grape-entity/pull/384): Fixed the `inspect` method to correctly handle nil values. - [@fcce](https://github.com/fcce). ### ### 1.0.1 (2024-04-10) diff --git a/spec/grape_entity/entity_spec.rb b/spec/grape_entity/entity_spec.rb index 466e4d7..2209ea9 100644 --- a/spec/grape_entity/entity_spec.rb +++ b/spec/grape_entity/entity_spec.rb @@ -1754,7 +1754,6 @@ class NoPathCharacterEntity < Grape::Entity end end end - describe '#inspect' do before do fresh_class.class_eval do @@ -1769,6 +1768,12 @@ class NoPathCharacterEntity < Grape::Entity expect(data).to_not include '@options' expect(data).to_not include '@delegator' end + + it 'returns a nil string when subject is nil' do + data = subject.class.new(nil).inspect + expect(data).to include 'nil' + end + end describe '#value_for' do