File: render_nil_test.rb

package info (click to toggle)
ruby-representable 3.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 896 kB
  • sloc: ruby: 6,432; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 495 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require "test_helper"

class RenderNilTest < Minitest::Spec
  Song = Struct.new(:title)

  describe "render_nil: true" do
    representer! do
      property :title, render_nil: true
    end

    it { Song.new.extend(representer).to_hash.must_equal({"title"=>nil}) }
  end

  describe "with :extend it shouldn't extend nil" do
    representer! do
      property :title, render_nil: true, extend: Class
    end

    it { Song.new.extend(representer).to_hash.must_equal({"title"=>nil}) }
  end
end