Sha256: 8a4e0a232ea998b30348ed5998d798a7713ce34db56d6e12d5b5a1cbf032d734
Contents?: true
Size: 1.03 KB
Versions: 10
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' describe 'Schema#walk' do let(:schema) do Paradocs::Schema.new do field(:title).meta(example: 'a title', label: 'custom title') field(:tags).policy(:array).meta(example: ['tag1', 'tag2'], label: 'comma-separated tags') field(:friends).policy(:array).schema do field(:name).meta(example: 'a friend', label: 'friend full name') field(:age).meta(example: 34, label: 'age') end end end it "recursively walks the schema and collects meta data" do results = schema.walk(:label) expect(results.output).to eq({ title: 'custom title', tags: 'comma-separated tags', friends: [ { name: 'friend full name', age: 'age' } ] }) end it "works with blocks" do results = schema.walk{|field| field.meta_data[:example]} expect(results.output).to eq({ title: 'a title', tags: ['tag1', 'tag2'], friends: [ { name: 'a friend', age: 34 } ] }) end end
Version data entries
10 entries across 10 versions & 1 rubygems