Sha256: 5cb04151b242400aa9cd74722d1e72be4fb9b85cc351a903d8836bbd7d52685a

Contents?: true

Size: 851 Bytes

Versions: 15

Compression:

Stored size: 851 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'}]
      object.links.should == [{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')
      object.links.should == [{url: 'http://example.com', note: 'homepage'}]
    end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pupa-0.1.11 spec/models/concerns/linkable_spec.rb
pupa-0.1.10 spec/models/concerns/linkable_spec.rb
pupa-0.1.9 spec/models/concerns/linkable_spec.rb
pupa-0.1.8 spec/models/concerns/linkable_spec.rb
pupa-0.1.7 spec/models/concerns/linkable_spec.rb
pupa-0.1.6 spec/models/concerns/linkable_spec.rb
pupa-0.1.5 spec/models/concerns/linkable_spec.rb
pupa-0.1.4 spec/models/concerns/linkable_spec.rb
pupa-0.1.3 spec/models/concerns/linkable_spec.rb
pupa-0.1.2 spec/models/concerns/linkable_spec.rb
pupa-0.1.1 spec/models/concerns/linkable_spec.rb
pupa-0.1.0 spec/models/concerns/linkable_spec.rb
pupa-0.0.13 spec/models/concerns/linkable_spec.rb
pupa-0.0.12 spec/models/concerns/linkable_spec.rb
pupa-0.0.11 spec/models/concerns/linkable_spec.rb