spec/schema_spec.rb in paradocs-1.1.3 vs spec/schema_spec.rb in paradocs-1.1.4
- old
+ new
@@ -14,11 +14,11 @@
end
end
subject do
described_class.new do
- field(:title).policy(:string).present
+ field(:title).policy(:string).present.as(:article_title)
field(:price).policy(:integer).meta(label: "A price")
field(:status).policy(:string).options(['visible', 'hidden'])
field(:tags).policy(:split).policy(:array)
field(:description).policy(:string)
field(:variants).policy(:array).schema do
@@ -31,12 +31,12 @@
end
describe "#structure" do
it "represents data structure and meta data" do
sc = subject.structure.nested
- expect(sc[:title][:present]).to be true
- expect(sc[:title][:type]).to eq :string
+ expect(sc[:article_title][:present]).to be true
+ expect(sc[:article_title][:type]).to eq :string
expect(sc[:price][:type]).to eq :integer
expect(sc[:price][:label]).to eq "A price"
expect(sc[:variants][:type]).to eq :array
sc[:variants][:structure].tap do |sc|
expect(sc[:name][:type]).to eq :string
@@ -74,11 +74,11 @@
]
}
output = subject.resolve(payload).output
expect(output).to eq({
- title: "title",
+ article_title: "title",
price: 100,
status: "visible",
tags: ["tag"],
variants: [
{
@@ -99,11 +99,11 @@
tags: 'tag1, tag2',
description: 'A description',
variants: [{name: 'v1', sku: 'ABC', stock: '10', available_if_no_stock: true}]
},
{
- title: 'iPhone 6 Plus',
+ article_title: 'iPhone 6 Plus',
price: 100,
status: 'visible',
tags: ['tag1', 'tag2'],
description: 'A description',
variants: [{name: 'v1', sku: 'ABC', stock: 10, available_if_no_stock: true}]
@@ -112,10 +112,10 @@
test_schema(subject, {
title: 'iPhone 6 Plus',
variants: [{name: 'v1', available_if_no_stock: '1'}]
},
{
- title: 'iPhone 6 Plus',
+ article_title: 'iPhone 6 Plus',
variants: [{name: 'v1', stock: 1, available_if_no_stock: true}]
})
resolve(subject, {}) do |results|
expect(results.valid?).to be false