Coder Social home page Coder Social logo

i18n-spec's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

i18n-spec's Issues

Rake tasks for fixing locales

Hi, i work with locale files and came across this gem to at least help with the task of synchronising locale files. So now i can use your rake tasks to check if there are missing keys.

But then i have to go and add them by hand. And I am a strong believer in not doing by hand what a machine can do, so i will be writing some task to do the synchronisation.

Off course i then have to go and do the actual translation, but at least i don't have to go back and forth.

So the question is: do you have such a task already (seems quite standard stuff), or is a part of some other gem, or would you accept a pull that does this?

Warnings on Ruby 1.8.7

When I run rake spec for rails-i18n on Ruby 1.8.7, I get following warnings.

/home/kuroda/.rvm/gems/ruby-1.8.7-p358@rails-i18n/gems/i18n-spec-0.2.0/lib/i18n-spec/matchers/have_legacy_interpolations.rb:1: warning: multiple values for a block parameter (0 for 1)
from /home/kuroda/.rvm/gems/ruby-1.8.7-p358@rails-i18n/gems/rspec-expectations-2.9.0/lib/rspec/matchers/extensions/instance_eval_with_args.rb:11

This warning shows itself repeatedly.

failure_for_should raises NoMethodError

If a test whit a matcher that use failure_for_should fails it raise a NoMethodError

  1) config/locales/cs.yml should be a subset of "config/locales/en.yml"
     Failure/Error: it { is_expected.to be_a_subset_of 'config/locales/en.yml' }
     NoMethodError:
       undefined method `join' for nil:NilClass
     # .../i18n-spec/lib/i18n-spec/matchers/be_a_subset_of_matcher.rb:14:in `block (2 levels) in <top (required)>'
     # .../i18n-spec/failure_message.rb:6:in `block in failure_for_should'
     # ./spec/unit/i18n_spec.rb:12:in `block (3 levels) in <top (required)>'
RSpec::Matchers.define :be_a_subset_of do |default_locale_filepath|
  extend I18nSpec::FailureMessage

  match do |filepath|
    locale_file = I18nSpec::LocaleFile.new(filepath)
    default_locale = I18nSpec::LocaleFile.new(default_locale_filepath)
    @superset = locale_file.flattened_translations.keys.reject do |key|
      default_locale.flattened_translations.keys.include?(key)
    end
    @superset.empty?
  end

  failure_for_should do |filepath|
    "expected #{filepath} to not include :\n- " << @superset.join("\n- ")
  end
end

I think the problem is that the instance variable is not shared between match and failure_for_should

rake aborted! uninitialized constant RSpec

[vagrant@vagrant ]$ bundle exec rake RAILS_ENV=test db:setup --trace
rake aborted!
uninitialized constant RSpec
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/i18n-spec-0.4.0/lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb:1:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/i18n-spec-0.4.0/lib/i18n-spec.rb:8:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/i18n-spec-0.4.0/lib/i18n-spec.rb:8:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/i18n-spec-0.4.0/lib/i18n-spec.rb:8:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
/home/vagrant/src/project/config/application.rb:8:in `<top (required)>'
/home/vagrant/src/project/Rakefile:5:in `require'
/home/vagrant/src/project/Rakefile:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:637:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:77:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake:23:in `<main>'
[vagrant@vagrant ]$

undefined method `failure_message_for_should' for class `Class' after upgrading to 0.5.1

I was using version 0.4.1 and I recently upgraded.

My spec is unchanged and still appears to match the example, but now I'm seeing failures like the following:

  1) Localization config/locales/en.yml
     Failure/Error: it { expect(have_missing_pluralization_keys).to be false }
     NameError:
       undefined method `failure_message_for_should_not' for class `Class'
     # ./spec/i18n/locales_spec.rb:16:in `block (3 levels) in <top (required)>'

  2) Localization config/locales/en.yml
     Failure/Error: it { should have_valid_pluralization_keys }
     NameError:
       undefined method `failure_message_for_should' for class `Class'
     # ./spec/i18n/locales_spec.rb:15:in `block (3 levels) in <top (required)>'

  3) Localization config/locales/en.yml
     Failure/Error: it { expect(be_parseable).to be true }
     NameError:
       undefined method `failure_message_for_should' for class `Class'
     # ./spec/i18n/locales_spec.rb:14:in `block (3 levels) in <top (required)>'

Any ideas?

i18n_spec fails on 'one' key missing outside of an activerecord model

I have a YAML structured like this, containing other keyword:

fr:
  something:
    other: 'autre'

i got that kind of messages:

expected config/locales/something/fr.yml to contain the following pluralization keys :
       - fr.something.one

and

expected config/locales/something/fr.yml to not contain invalid pluralization keys in the following namespaces :
       - fr.something

I had to disable the pluralization validations after having disabled the global shared behaviour:

it_behaves_like 'a valid locale file'

to enable all the expectations one by one but the 2 related to pluralization:

      it { is_expected.to be_parseable }
      # it { is_expected.to have_valid_pluralization_keys }
      # it { is_expected.to_not have_missing_pluralization_keys }
      it { is_expected.to have_one_top_level_namespace }
      it { is_expected.to be_named_like_top_level_namespace }
      it { is_expected.to_not have_legacy_interpolations }
      it { is_expected.to have_a_valid_locale }

spec coverage

During the working on #16 and #17, I found that the failure_for_should is not spec coverage on be_a_complete_translation_of and be_a_subset_of

no implicit conversion of Module into String on basic example

Hi there,

I have been trying to use the first example to test this library's suitability for testing yaml files, and I am unable to carry out the basic 'hello world' example for testing a locale file. The following block is what I used:

spec/i18n/locales_spec.rb

require 'rails_helper'

RSpec.describe I18n do
  describe "config/locales/en.yml" do
    it { is_expected.to be_parseable }
  end
end

And my error message is as follows:

1) I18n config/locales/en.yml should be parseable
     Failure/Error: it { is_expected.to be_parseable }

     TypeError:
       no implicit conversion of Module into String

And I also have a config/locales/en.yml file with the following content:

en:
  default_mailer:
    subject: "Message from %{name}"
    from_name: "%{name} Team"

Finally, I'm using the following versions:
Globalize: 5.1.0.beta2
rails-i18n: 5
rails: 5.1

If this is user error on my part, I'd be happy to offer an update the docs with a clear example on the Readme so that other jr devs will find less of a barrier to adoption. Thanks in advance for taking the time to read!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.