Sha256: 770097263c3449251d4fde77c9aa66d0be83c999dd38a3e213a3b31b0fe56815

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

require 'pr/fields/generic_field'
require 'pr/define_field'

describe 'defining a field on a form' do
  let(:field)         { PR::Fields::GenericField }
  let(:form_klass)    { Class.new }
  let(:form)          { form_klass.new }
  let(:new_raw_value) { double "new raw field value" }
  let(:define_field)  { DefineField.new }

  it 'defines a reader to return the raw value of the field' do
    define_field.on form_klass, :name, field
    expect(form.name).to eq field.new.raw
  end
  it 'defines a writer which will set the field value' do
    define_field.on form_klass, :name, field
    form.name = new_raw_value
    expect(form.name).to eq new_raw_value
  end
  it 'defines a reader to return the actual field' do
    define_field.on form_klass, :name, field
    expect(form.__name).to be_a field
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pr-0.0.1 spec/unit/pr/define_field_spec.rb