diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-01 21:14:58 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-01 21:55:51 +0900 |
commit | ab516e263c06fbd755d4805ad529c32b1b8292b5 (patch) | |
tree | f709104c313268e8443174ab03242fc1e8f6c39c /spec/ruby/core/env/spec_helper.rb | |
parent | 4e03a7298b3a99de9c57f9a4934d38445cad1b10 (diff) | |
download | ruby-ab516e263c06fbd755d4805ad529c32b1b8292b5.tar.gz |
[ruby/spec] Fix failures with LC_ALL=C
https://github.com/ruby/spec/commit/51047687c0
https://github.com/ruby/spec/commit/2b87b467cc
Diffstat (limited to 'spec/ruby/core/env/spec_helper.rb')
-rw-r--r-- | spec/ruby/core/env/spec_helper.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/core/env/spec_helper.rb b/spec/ruby/core/env/spec_helper.rb new file mode 100644 index 0000000000..470ffa58bc --- /dev/null +++ b/spec/ruby/core/env/spec_helper.rb @@ -0,0 +1,26 @@ +require_relative '../../spec_helper' + +locale_env_matcher = Class.new do + def initialize(name = 'locale') + encoding = Encoding.find(name) + @encodings = (encoding = Encoding::US_ASCII) ? + [encoding, Encoding::ASCII_8BIT] : [encoding] + end + + def matches?(actual) + @actual = actual = actual.encoding + @encodings.include?(actual) + end + + def failure_message + ["Expected #{@actual} to be #{@encodings.join(' or ')}"] + end + + def negative_failure_message + ["Expected #{@actual} not to be #{@encodings.join(' or ')}"] + end +end + +String.__send__(:define_method, :be_locale_env) do |expected = 'locale'| + locale_env_matcher.new(expected) +end |