Sha256: 6b438c01702c3c7b1e5ae4827c21075d50e05a90d3d5dfcf316f2a821bb2f79e

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

RSpec.describe Yaks::Resource::Form::Field do
  subject do
    described_class.new(value: 123)
  end

  describe '#value' do
    its(:value) { should eql 123 }

    context 'with a select box - with selection' do
      subject do
        described.class.new(type: :select, options: [
                              Yaks::Resource::Form::Field::Option.new(selected: false, value: 1),
                              Yaks::Resource::Form::Field::Option.new(selected: true, value: 2),
                              Yaks::Resource::Form::Field::Option.new(selected: false, value: 3),
                            ])
      end

      it 'should return the selected value' do
        expect( subject.value ).to eql 2
      end
    end

    context 'with a select box - no selection' do
      subject do
        described.class.new(type: :select, options: [
                              Yaks::Resource::Form::Field::Option.new(selected: false, value: 1),
                              Yaks::Resource::Form::Field::Option.new(selected: false, value: 2),
                              Yaks::Resource::Form::Field::Option.new(selected: false, value: 3),
                            ])
      end

      it 'should return nothing' do
        expect( subject.value ).to be nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaks-0.8.0.beta1 spec/unit/yaks/resource/form/field_sepc.rb