Sha256: f6e0422a9b71149a9d473f6ae57572dd923b80ae1ef6b0c0630c27139a1298d1

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# encoding: UTF-8

require 'yaml'
require 'spec_helper'
require 'cldr-plurals/ruby_runtime'

include CldrPlurals
include CldrPlurals::Compiler

describe 'ruby rules;' do
  Samples.each_rule do |locales, rule, samples|
    context "locales: #{locales}, rule: #{rule.name};" do
      ruby_code = RubyEmitter.emit_rule_standalone(rule)
      rule_proc = eval(ruby_code)

      samples.each do |sample_info|
        context "#{sample_info[:type]} samples" do
          sample_info[:samples].each do |sample|
            it sample do
              args = RubyRuntime.build_args_for(sample)
              expect(rule_proc.call(*args)).to eq(true)
            end
          end
        end
      end
    end
  end
end

describe 'ruby rule lists' do
  Samples.each_rule_list do |rule_list, samples_per_name|
    context rule_list.locale do
      ruby_code = rule_list.to_code(:ruby)
      rule_proc = eval(ruby_code)

      samples_per_name.each_pair do |name, samples|
        samples.each do |sample|
          it "#{name} #{sample}" do
            expect(rule_proc.call(sample, RubyRuntime)).to eq(name)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cldr-plurals-1.2.0 spec/ruby_sample_spec.rb