Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OgnianApostolov opened this issue May 8, 2018 · 1 comment

Comments

@OgnianApostolov
Copy link

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)>
@emaglio
Copy link
Member

emaglio commented Oct 10, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants