Sha256: 18eb193cdfac51b5cbb2888b65a7084d3a39bb416bd74e2f5a9ce681cd3e69d5

Contents?: true

Size: 1.22 KB

Versions: 22

Compression:

Stored size: 1.22 KB

Contents

require File.join( File.dirname(__FILE__), '../lib/blackbook.rb' )
require File.join( File.dirname(__FILE__), 'test_helper.rb' )
require 'test/unit'
require 'mocha'

class TestBlackbookExporterVcf < Test::Unit::TestCase

  include TestHelper

  def setup
    @card = Blackbook::Exporter::Vcf::Vcard.new(
             {'first' => 'joe', 'last' => 'user', 
              'email' => 'joe.user@example.com'})
    @exporter = Blackbook::Exporter::Vcf.new
  end

  def test_vcard
    assert_equal 'joe', @card.first
    assert_equal 'user', @card.last
    assert_equal 'joe.user@example.com', @card.email
  end

  def test_vcard_to_s
    card = %q!BEGIN:VCARD
N:user;joe
EMAIL:joe.user@example.com
END:VCARD
!
    assert_equal card, @card.to_s
    assert_equal 'user', @card.last
    assert_equal 'joe.user@example.com', @card.email
  end

  def test_export
    contacts = [{ :name => 'Test', :email => 'test@example.com' }]
    expected = <<VCF
BEGIN:VCARD
N:;Test
EMAIL:test@example.com
END:VCARD
VCF
    exported = @exporter.export(contacts)
    assert_equal 1, exported.size
    assert_equal expected, exported.first.to_s
  end

  def test_export_when_contacts_blank
    assert_nil @exporter.export()
    assert_nil @exporter.export([])
  end

end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
alexjp-blackbook_csv-1.0.5 test/test_blackbook_exporter_vcf.rb
alexjp-blackbook_csv-3.0.1 test/test_blackbook_exporter_vcf.rb
alexjp-blackbook_csv-3.0.2 test/test_blackbook_exporter_vcf.rb
bcardarella-blackbook-1.0.10 test/test_blackbook_exporter_vcf.rb
bcardarella-blackbook-1.0.11 test/test_blackbook_exporter_vcf.rb
bcardarella-blackbook-1.0.7 test/test_blackbook_exporter_vcf.rb
bcardarella-blackbook-1.0.8 test/test_blackbook_exporter_vcf.rb
bcardarella-blackbook-1.0.9 test/test_blackbook_exporter_vcf.rb
briancollins-blackbook-1.0.15 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.12 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.13 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.14 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.15 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.16 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.17 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.18 test/test_blackbook_exporter_vcf.rb
rakutenusa-blackbook-1.0.19 test/test_blackbook_exporter_vcf.rb
blackbook-1.0.3 test/test_blackbook_exporter_vcf.rb
blackbook-1.0.2 test/test_blackbook_exporter_vcf.rb
blackbook-1.0.1 test/test_blackbook_exporter_vcf.rb