Sha256: 63e8283f3d185b7b96b7ee155fbe278bd9e2881a146b9953efd48da94fa33052

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

require 'pr/fields/string_field'

describe 'a string field' do
  let(:klass)   { PR::Fields::StringField }
  let(:value)   { double "value" }
  let(:options) { Hash.new }
  let(:field)   { klass.new value, options }

  describe "default value" do
    specify { expect(klass.new.raw).to eq '' }
    specify { expect(klass.new.convert).to eq '' }
    specify { expect(klass.new.options).to eq({}) }
  end

  describe '#options' do
    it 'has retrievable options' do
      expect(field.options).to eq options
    end
  end

  describe "#populate" do
    subject { field.populate value }
    specify { expect(field.raw).to eq(value) }
  end

  describe :raw do
    it "should return the value the field was initialized with" do
      expect(field.raw).to eq(value)
    end
  end

  describe :convert do
    it "should return the string version of value" do
      expect(value).to receive(:to_s).and_return "string value"
      expect(field.convert).to eq("string value")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pr-1.0.0 spec/unit/pr/fields/string_field_spec.rb
pr-0.0.7 spec/unit/pr/fields/string_field_spec.rb