Sha256: 6a5015f85fe3071ae5c3eaa65f4ff1c8235d161ee82f90f282f3e1b0d7e379cc

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'rspec'
require 'twitter_cldr'
require 'pry-byebug'
require 'coveralls'
require 'eprun'

Coveralls.wear!

if ENV['SCOV']
  require 'simplecov'
  SimpleCov.start
  puts 'Running simplecov'
end

class FastGettext
  class << self
    @@locale = :en

    def locale
      @@locale
    end

    def locale=(new_locale)
      @@locale = new_locale
    end
  end
end

module I18n
  class << self
    @@locale = :en

    def locale
      @@locale
    end

    def locale=(new_locale)
      @@locale = new_locale
    end
  end
end

RSpec.configure do |config|
  # config.mock_with :rr

  config.filter_run(focus: true)
  config.run_all_when_everything_filtered = true
  config.filter_run_excluding(slow: true) unless ENV['FULL_SPEC']

  config.before(:each) do
    TwitterCldr.reset_locale_fallbacks
    TwitterCldr.locale = :en
    FastGettext.locale = :en
    I18n.locale = :en
  end
end

RSpec::Matchers.define :match_normalized do |expected|
  match do |actual|
    Eprun.normalize(expected, :nfkc) == Eprun.normalize(actual, :nfkc)
  end
end

RSpec::Matchers.define :exactly_match do |expected|
  match do |actual|
    if actual.respond_to?(:match)
      m = actual.match(expected)
      m.to_a.first == expected
    else
      expected === actual
    end
  end
end

def check_token_list(got, expected)
  expect(got.size).to eq(expected.size)
  expected.each_with_index do |exp_hash, index|
    exp_hash.each_pair do |exp_key, exp_val|
      expect(got[index].send(exp_key)).to eq(exp_val)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
twitter_cldr-6.11.5 spec/spec_helper.rb
twitter_cldr-6.11.4 spec/spec_helper.rb
twitter_cldr-6.11.3 spec/spec_helper.rb
twitter_cldr-6.11.2 spec/spec_helper.rb
twitter_cldr-6.11.1 spec/spec_helper.rb
twitter_cldr-6.11.0 spec/spec_helper.rb
twitter_cldr-6.10.0 spec/spec_helper.rb
twitter_cldr-6.9.0 spec/spec_helper.rb
twitter_cldr-6.8.0 spec/spec_helper.rb
twitter_cldr-6.7.0 spec/spec_helper.rb
twitter_cldr-6.6.2 spec/spec_helper.rb
twitter_cldr-6.6.1 spec/spec_helper.rb