Sha256: edf42e733be1cc1a2b4fdf2e40b4337f62f2274afd1639f0206d0d4a8d146b8c

Contents?: true

Size: 626 Bytes

Versions: 5

Compression:

Stored size: 626 Bytes

Contents

require 'spec_helper'
require 'napa/output_formatters/include_nil'
require 'napa/grape_extensions/grape_helpers'
require 'pry'

describe Napa::Representable::IncludeNil do
  class FooRepresenter < Napa::Representer
    include Napa::Representable::IncludeNil
    property :foo
    property :bar
  end

  class DummyClass
    include Napa::GrapeHelpers
  end

  it 'includes nil keys in a represented hash' do
    input = OpenStruct.new(foo: 1, bar: nil)
    output = DummyClass.new.represent(input, with: FooRepresenter).to_h
    expect(output[:data]).to have_key('foo')
    expect(output[:data]).to have_key('bar')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
napa-0.5.0 spec/grape_extensions/include_nil_spec.rb
napa-0.4.3 spec/grape_extensions/include_nil_spec.rb
napa-0.4.1 spec/grape_extensions/include_nil_spec.rb
napa-0.4.0 spec/grape_extensions/include_nil_spec.rb
napa-0.3.0 spec/grape_extensions/include_nil_spec.rb