File: render_nil_test.rb

package info (click to toggle)
ruby-representable 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 952 kB
  • sloc: ruby: 6,495; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 501 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