spec/grape_entity/entity_spec.rb in grape-entity-0.10.2 vs spec/grape_entity/entity_spec.rb in grape-entity-1.0.0
- old
+ new
@@ -28,11 +28,13 @@
expect { subject.expose :name, as: :foo }.not_to raise_error
end
it 'makes sure that :format_with as a proc cannot be used with a block' do
# rubocop:disable Style/BlockDelimiters
+ # rubocop:disable Lint/Debugger
expect { subject.expose :name, format_with: proc {} do p 'hi' end }.to raise_error ArgumentError
+ # rubocop:enable Lint/Debugger
# rubocop:enable Style/BlockDelimiters
end
it 'makes sure unknown options are not silently ignored' do
expect { subject.expose :name, unknown: nil }.to raise_error ArgumentError
@@ -243,12 +245,12 @@
end
context 'when default option is set' do
it 'exposes default values for attributes' do
subject.expose(:a, default: 'a')
- subject.expose(:b, default: 'b')
+ subject.expose(:b, default: false)
subject.expose(:c, default: 'c')
- expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: 'b', c: 'value')
+ expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: false, c: 'value')
end
end
context 'when default option is set and block passed' do
it 'return default value if block returns nil' do