Sha256: aed5461e79dcc2f37693f9bc320ccd1f51c56641dd4632f0ef329cc46485ec6d

Contents?: true

Size: 866 Bytes

Versions: 5

Compression:

Stored size: 866 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Pupa::Concerns::Linkable do
  let :klass do
    Class.new do
      include Pupa::Model
      include Pupa::Concerns::Linkable
    end
  end

  let :object do
    klass.new
  end

  describe '#links' do
    it 'should symbolize keys' do
      object.links = [{'url' => 'http://example.com', 'note' => 'homepage'}]
      expect(object.links).to eq([{url: 'http://example.com', note: 'homepage'}])
    end
  end

  describe '#add_link' do
    it 'should add a link' do
      object.add_link('http://example.com', note: 'homepage')
      expect(object.links).to eq([{url: 'http://example.com', note: 'homepage'}])
    end

    it 'should not add a link without a url' do
      object.add_link(nil)
      object.add_link('')
      expect(object.links.blank?).to eq(true)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.2.4 spec/models/concerns/linkable_spec.rb
pupa-0.2.3 spec/models/concerns/linkable_spec.rb
pupa-0.2.2 spec/models/concerns/linkable_spec.rb
pupa-0.2.1 spec/models/concerns/linkable_spec.rb
pupa-0.2.0 spec/models/concerns/linkable_spec.rb