Sha256: b53dc10d1c0a862b315b3432ddf9070f6103e3dad2afadff04bf65be2b68a902

Contents?: true

Size: 949 Bytes

Versions: 5

Compression:

Stored size: 949 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
    subject { klass.new }

    its(:raw)     { should == '' }
    its(:convert) { should == '' }
    its(:options) { should == {} }
  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 { field.raw.should == value }
  end

  describe :raw do
    it "should return the value the field was initialized with" do
      field.raw.should == value
    end
  end

  describe :convert do
    it "should return the string version of value" do
      value.should_receive(:to_s).and_return "string value"
      field.convert.should == "string value"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pr-0.0.6 spec/unit/pr/fields/string_field_spec.rb
pr-0.0.5 spec/unit/pr/fields/string_field_spec.rb
pr-0.0.4 spec/unit/pr/fields/string_field_spec.rb
pr-0.0.3 spec/unit/pr/fields/string_field_spec.rb
pr-0.0.2 spec/unit/pr/fields/string_field_spec.rb