Sha256: 5e5da114547218f323e354a816e03e0b53043b4645804f2def6ea9c72adafbca

Contents?: true

Size: 440 Bytes

Versions: 3

Compression:

Stored size: 440 Bytes

Contents

require 'spec_helper'

class Cat
  include Id::Model
end

class OptionalModel
  include Id::Model

  has_one :cat, optional: true
end

module Id
  module Model

    describe HasOneOption do

      it 'returns a none if the key is missing' do
        OptionalModel.new({}).cat.should be_none
      end

      it 'returns a some if the key is there' do
        OptionalModel.new(cat: {}).cat.should be_some(Cat)
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
id-0.0.9 spec/lib/id/model/has_one_spec.rb
id-0.0.8 spec/lib/id/model/has_one_spec.rb
id-0.0.7 spec/lib/id/model/has_one_spec.rb