Sha256: 3c8cccc50b9045a00cab90993f7b150d66c25f99e67cc9d8ac28be55213e2565

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

require 'rails_helper'

describe PgFormBuilder do
  let(:categoria) { create :categoria_de_cosa }
  let(:template) { double }
  let(:instancia) { described_class.new('bla', categoria, template, {}) }

  before { create_list :cosa, 2, categoria_de_cosa: categoria }

  describe '#mensaje' do
    subject { instancia.mensaje }

    context 'cuando solo tiene errores de presencia' do
      before do
        categoria.nombre = nil
        categoria.validate
      end

      it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
    end

    context 'cuando solo tiene errores de presencia en nested' do
      before do
        categoria.reload
        categoria.cosas[0].nombre = nil
        categoria.validate
      end

      it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
    end
  end

  describe '#default_prefix' do
    context 'cuando el atributo es masculino' do
      subject { instancia.default_prefix(:nombre) }

      it { expect(subject).to eq 'El nombre' }
    end

    context 'cuando el atributo es femenino' do
      subject { instancia.default_prefix(:fecha) }

      it { expect(subject).to eq 'La fecha' }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.26 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.25 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.24 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.23 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.22 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.21 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.20 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.19 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.18 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.17 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.16 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.15 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.14 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.13 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.12 pg_engine/spec/lib/pg_form_builder_spec.rb
pg_rails-7.0.8.pre.alpha.11 pg_engine/spec/lib/pg_form_builder_spec.rb