Sha256: d557872ba241807207d99fff001f86d214bba3c740e8967d132ccffd3d2a98bc

Contents?: true

Size: 883 Bytes

Versions: 8

Compression:

Stored size: 883 Bytes

Contents

RSpec.describe 'dynamic form fields' do
  let(:mapper) do
    Class.new(Yaks::Mapper) do
      type :awesome
      form :foo do
        text :name
        dynamic do |object|
          object.each do |x|
            text x
          end
        end
      end
    end
  end

  let(:yaks) { Yaks.new }
  let(:object) { [:a, :b, :c] }

  it 'should create dynamic form fields' do

    expect(yaks.map(object, mapper: mapper)).to eql Yaks::Resource.new(
      type: :awesome,
      forms: [
        Yaks::Resource::Form.new(
          name: :foo,
          fields: [
            Yaks::Resource::Form::Field.new(name: :name, type: :text),
            Yaks::Resource::Form::Field.new(name: :a, type: :text),
            Yaks::Resource::Form::Field.new(name: :b, type: :text),
            Yaks::Resource::Form::Field.new(name: :c, type: :text)
          ]
        )
      ]
    )
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yaks-0.9.0 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.3 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.2 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.1 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.0 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.0.beta2 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.0.beta1 spec/integration/dynamic_form_fields_spec.rb
yaks-0.8.0.alpha spec/integration/dynamic_form_fields_spec.rb