blob: fe94ea3a69a75e3483c78ed22d6447789e35ca16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::Entities::Nuget::Metadatum do
let(:metadatum) do
{
project_url: 'http://sandbox.com/project',
license_url: 'http://sandbox.com/license',
icon_url: 'http://sandbox.com/icon'
}
end
let(:expected) do
{
'projectUrl': 'http://sandbox.com/project',
'licenseUrl': 'http://sandbox.com/license',
'iconUrl': 'http://sandbox.com/icon'
}
end
let(:entity) { described_class.new(metadatum) }
subject { entity.as_json }
it { is_expected.to eq(expected) }
%i[project_url license_url icon_url].each do |optional_field|
context "metadatum without #{optional_field}" do
let(:metadatum_without_a_field) { metadatum.except(optional_field) }
let(:expected_without_a_field) { expected.except(optional_field.to_s.camelize(:lower).to_sym) }
let(:entity) { described_class.new(metadatum_without_a_field) }
it { is_expected.to eq(expected_without_a_field) }
end
end
end
|