Sha256: ad41dc22f38f71dc1479b24217a4f1fbbc2bf19fcda72fff641ce7864ecd2b88

Contents?: true

Size: 1.14 KB

Versions: 45

Compression:

Stored size: 1.14 KB

Contents

require 'rails_helper'

shared_examples_for :person do
  let(:model) { described_class }
  let(:klass) { model.to_s.underscore.to_sym }

  it :full_name do
    person = build(klass, first_name: 'Foo', last_name: 'Bar')
    expect(person.full_name).to eq 'Foo Bar'
  end

  describe '#short_name' do
    it 'no first name' do
      person = build(klass, first_name: nil, last_name: 'Bar')
      expect(person.short_name).to eq 'B.'
    end

    it 'no last name' do
      person = build(klass, first_name: 'Foo', last_name: nil)
      expect(person.short_name).to eq 'Foo'
    end

    it 'last name with 1 word' do
      person = build(klass, first_name: 'Foo', last_name: 'Bar')
      expect(person.short_name).to eq 'Foo B.'
    end

    it 'last name with 2 words' do
      person = build(klass, first_name: 'Foo', last_name: 'Bar Baz')
      expect(person.short_name).to eq 'Foo B.B.'
    end

    it 'last name with 3 words' do
      person = build(klass, first_name: 'Foo', last_name: 'Bar Baz Boz')
      expect(person.short_name).to eq 'Foo B.B.B.'
    end
  end

  it '#respond_to?' do
    expect(model.new).to respond_to(:full_name, :short_name)
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
udongo-7.2.0 spec/support/concerns/person.rb
udongo-7.1.3 spec/support/concerns/person.rb
udongo-7.1.2 spec/support/concerns/person.rb
udongo-7.1.1 spec/support/concerns/person.rb
udongo-7.1.0 spec/support/concerns/person.rb
udongo-7.0.4 spec/support/concerns/person.rb
udongo-7.0.3 spec/support/concerns/person.rb
udongo-7.0.2 spec/support/concerns/person.rb
udongo-7.0.1 spec/support/concerns/person.rb
udongo-7.0.0 spec/support/concerns/person.rb
udongo-6.6.3 spec/support/concerns/person.rb
udongo-6.6.2 spec/support/concerns/person.rb
udongo-6.6.1 spec/support/concerns/person.rb
udongo-6.6.0 spec/support/concerns/person.rb
udongo-6.5.2 spec/support/concerns/person.rb
udongo-6.5.1 spec/support/concerns/person.rb
udongo-6.5.0 spec/support/concerns/person.rb
udongo-6.4.1 spec/support/concerns/person.rb
udongo-6.4.0 spec/support/concerns/person.rb
udongo-6.3.2 spec/support/concerns/person.rb