Sha256: 4df43594ddca96e5cf63a281875462172a07abe89246d6dffa702f818772ce2c

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 Bytes

Contents

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

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

  let :object do
    klass.new
  end

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

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

    it 'should not add a source without a url' do
      object.add_source(nil)
      object.add_source('')
      expect(object.sources.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/sourceable_spec.rb
pupa-0.2.3 spec/models/concerns/sourceable_spec.rb
pupa-0.2.2 spec/models/concerns/sourceable_spec.rb
pupa-0.2.1 spec/models/concerns/sourceable_spec.rb
pupa-0.2.0 spec/models/concerns/sourceable_spec.rb