describe Ppl::Service::Name do

  before(:each) do
    @service = Ppl::Service::Name.new
    @name = Ppl::Entity::Name.new
  end

  describe "#parse" do

    it "uses the whole string for the full name" do
      expect(@service.parse("John Smith").full).to eq "John Smith"
    end

    it "uses the first word for the given name" do
      expect(@service.parse("John Smith").given).to eq "John"
    end

    it "uses the rest of the string for the family names" do
      expect(@service.parse("John Fitzgerald Donald Smith").family).to eq "Fitzgerald Donald Smith"
    end

  end

  describe "#update" do

    it "updates the full name" do
      @service.update(@name, {:full => "Abc Def"})
      expect(@name.full).to eq "Abc Def"
    end

    it "updates the given names" do
      @service.update(@name, {:given => "John"})
      expect(@name.given).to eq "John"
    end

    it "updates the family names" do
      @service.update(@name, {:family => "Smith"})
      expect(@name.family).to eq "Smith"
    end

    it "updates the middle names" do
      @service.update(@name, {:middle => "Arnold"})
      expect(@name.middle).to eq "Arnold"
    end

    it "updates the name prefix" do
      @service.update(@name, {:prefix => "Mr"})
      expect(@name.prefix).to eq "Mr"
    end

    it "updates the name suffix" do
      @service.update(@name, {:suffix => "BSc"})
      expect(@name.suffix).to eq "BSc"
    end

  end

end

