Sha256: b33e07c619375d0345849452dfb32a2df278b00dae1e088e8f4da4f8aff42a35

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

module Spec
  module Matchers
    class << self
      
      RSPEC_MATCHERS = [ :be_close, :be_an_instance_of, :be_a_kind_of,
                         :eql, :equal, :exist, :have, :have_at_least, 
                         :have_at_most, :have_exactly, :include, :match, 
                         :raise_error, :satisfy ]
      
      MATCHERS_WITH_QUESTIONS = [ :eql, :equal ]
      
      def translate_basic_matchers
        language = SpecI18n.natural_language        
        RSPEC_MATCHERS.each do |rspec_matcher|
          matcher = language.keywords['matchers'][rspec_matcher.to_s]

          # TODO: Generating warnings for the incomplete languages
          next unless matcher

          matcher.split('|').map do |matcher_value|
            alias_method "#{matcher_value}?", "#{rspec_matcher}?" if MATCHERS_WITH_QUESTIONS.include?(rspec_matcher)
            alias_method matcher_value, rspec_matcher
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-i18n-1.1.0 lib/spec-i18n/matchers/translate_basic_matchers.rb
rspec-i18n-1.0.0 lib/spec-i18n/matchers/translate_basic_matchers.rb