reform icon indicating copy to clipboard operation
reform copied to clipboard

reform-2.2.4: dry-validation mismatched translations when using Rspec

Open OgnianApostolov opened this issue 6 years ago • 1 comments

I’ve got some problems with dry validation translations into the Reform::Form. I have some contracts with the following configuration

class New < Reform::Form
.
.
.
 configure do
        config.messages = :i18n
        config.namespace = :administration_project_type
      end
.
.
.
class New < Reform::Form
.
.
.
configure do
        config.messages = :i18n
        config.namespace = :administration_job_title
      end
.
.
.

I also have some tests for those that go like this

it "project type must be filled" do
      subject.name = nil
      subject.valid?
      expect(subject.errors[:name]).to include("Project type must be filled")
    end
it "job title must be filled" do
      subject.name = nil
      subject.valid?
      expect(subject.errors[:name]).to include("Job Title must be filled")
    end

My locales look like this

en:
  errors:
    rules:
      administration_project_type:
        rules:
          name:
            filled?: "Project type must be filled"
            unique_name?: "Project type name must be unique"
en:
  errors:
    rules:
      administration_job_title:
        rules:
          name:
            filled?: "Job Title must be filled"
            unique_name?: "Job Title name must be unique"

I’m testing with Rspec. If I am to run the tests separately, they work fine. But when I run all tests, then I get errors such as

4) Administration::JobTitle::Contract::New validation job title must be filled
     Failure/Error: expect(subject.errors[:name]).to include("Job Title must be filled")
       expected ["Project subtype must be filled"] to include "Job Title must be filled"
     # ./spec/concepts/administration/job_title/contract/new_spec.rb:15:in `block (3 levels) in <top (required)>'
7) Administration::ProjectType::Contract::New validation project type must be filled
     Failure/Error: expect(subject.errors[:name]).to include("Project type must be filled")
       expected ["Project subtype must be filled"] to include "Project type must be filled"
     # ./spec/concepts/administration/project_type/contract/new_spec.rb:15:in `block (3 levels) in <top (required)>

OgnianApostolov avatar May 08 '18 14:05 OgnianApostolov

@OgnianApostolov it would be great if you could test this on the v2.3.0.rc2 branch :+1:

emaglio avatar Oct 10 '19 05:10 emaglio