Sha256: fb020dfff440d61db1546c83076a02672c26f808500b5aae68fddb4230573415

Contents?: true

Size: 877 Bytes

Versions: 15

Compression:

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

    it 'should not add a source without a url' do
      object.add_source(nil)
      object.add_source('')
      object.sources.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/sourceable_spec.rb
pupa-0.1.10 spec/models/concerns/sourceable_spec.rb
pupa-0.1.9 spec/models/concerns/sourceable_spec.rb
pupa-0.1.8 spec/models/concerns/sourceable_spec.rb
pupa-0.1.7 spec/models/concerns/sourceable_spec.rb
pupa-0.1.6 spec/models/concerns/sourceable_spec.rb
pupa-0.1.5 spec/models/concerns/sourceable_spec.rb
pupa-0.1.4 spec/models/concerns/sourceable_spec.rb
pupa-0.1.3 spec/models/concerns/sourceable_spec.rb
pupa-0.1.2 spec/models/concerns/sourceable_spec.rb
pupa-0.1.1 spec/models/concerns/sourceable_spec.rb
pupa-0.1.0 spec/models/concerns/sourceable_spec.rb
pupa-0.0.13 spec/models/concerns/sourceable_spec.rb
pupa-0.0.12 spec/models/concerns/sourceable_spec.rb
pupa-0.0.11 spec/models/concerns/sourceable_spec.rb