demarches-normaliennes/spec/helpers/etablissement_helper_spec.rb

65 lines
1.8 KiB
Ruby
Raw Normal View History

2018-04-23 11:57:54 +02:00
RSpec.describe EtablissementHelper, type: :helper do
let(:code_effectif) { '00' }
let(:raison_sociale) { 'GRTGaz' }
let(:nom) { 'mon nom' }
let(:prenom) { 'mon prenom' }
2015-08-20 17:30:17 +02:00
let(:entreprise_params) do
{
2018-04-23 11:57:54 +02:00
entreprise_capital_social: 123_000,
entreprise_code_effectif_entreprise: code_effectif,
entreprise_raison_sociale: raison_sociale,
entreprise_nom: nom,
entreprise_prenom: prenom
}
2015-08-20 17:30:17 +02:00
end
2018-04-23 11:57:54 +02:00
let(:etablissement) { create(:etablissement, entreprise_params) }
describe '#raison_sociale_or_name' do
2018-04-23 11:57:54 +02:00
subject { raison_sociale_or_name(etablissement) }
context 'when raison_sociale exist' do
let(:raison_sociale) { 'ma super raison_sociale' }
it 'display raison_sociale' do
expect(subject).to eq(raison_sociale)
end
end
2018-04-23 11:57:54 +02:00
context 'when raison_sociale is nil' do
let(:raison_sociale) { nil }
it 'display nom and prenom' do
2018-01-15 21:41:16 +01:00
expect(subject).to eq("#{nom} #{prenom}")
end
end
end
describe '#effectif' do
2018-04-23 11:57:54 +02:00
subject { effectif(etablissement) }
context 'when code_effectif is 00' do
let(:code_effectif) { '01' }
it { is_expected.to eq('1 ou 2 salariés') }
end
2018-04-23 11:57:54 +02:00
context 'when code_effectif is 32' do
let(:code_effectif) { '32' }
it { is_expected.to eq('250 à 499 salariés') }
end
end
2018-04-23 11:57:54 +02:00
describe '#pretty_currency' do
subject { pretty_currency(etablissement.entreprise_capital_social) }
it { is_expected.to eq('123 000,00 €') }
end
2020-06-03 17:04:58 +02:00
describe '#pretty_currency with special unit' do
subject { pretty_currency(12345, unit: 'k€') }
it { is_expected.to eq('12 345,00 k€') }
end
2020-06-03 17:04:58 +02:00
describe '#pretty_date_exercice' do
subject { pretty_date_exercice("201908") }
it { is_expected.to eq("2019") }
2020-06-03 17:04:58 +02:00
end
2015-08-20 17:30:17 +02:00
end