Sha256: 3887f7a46f3d6dfbbad8a327df84d0835dd31f553e46b5885d88ad39e6d9836c
Contents?: true
Size: 995 Bytes
Versions: 7
Compression:
Stored size: 995 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 it 'takes options and passes them to field' do options = Hash.new define_field.on form_klass, :name, field, options expect(form.__name.options).to eq options end end
Version data entries
7 entries across 7 versions & 1 rubygems