Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 小型测试和非拉丁测试描述_Ruby_Testing_Unicode_Utf 8_Minitest - Fatal编程技术网

Ruby 小型测试和非拉丁测试描述

Ruby 小型测试和非拉丁测试描述,ruby,testing,unicode,utf-8,minitest,Ruby,Testing,Unicode,Utf 8,Minitest,Ruby 1.9有很酷的Unicode支持,是吗 # encoding: utf-8 require 'minitest/spec' require 'minitest/autorun' describe "test" do it "α β γ δ & a b c d" do (1+1).must_equal 3 end end # 1) Failure: # test_0001__a_b_c_d(TestSpec) [test.rb:7]: # Expected 3

Ruby 1.9有很酷的Unicode支持,是吗

# encoding: utf-8
require 'minitest/spec'
require 'minitest/autorun'

describe "test" do
  it "α β γ δ & a b c d" do
    (1+1).must_equal 3
  end
end

# 1) Failure:
# test_0001__a_b_c_d(TestSpec) [test.rb:7]:
# Expected 3, not 2.
我的非拉丁字母在哪里?我应该总是用我糟糕的英语写我的测试

因为我可以用任何Unicode符号定义方法:

def α_β_γ_δ_a_b_c_d
  puts "geeeek"
end

α_β_γ_δ_a_b_c_d
#=> "geeeek"
PS我的问题似乎不清楚。我想问一下如何制作minitest的失败描述来显示我的非拉丁语定义。

它是关于。它在使用
/\s+/
进行猴子修补后显示utf-8字符

# encoding: utf-8
require 'minitest/spec'
require 'minitest/autorun'

class MiniTest::Spec < MiniTest::Unit::TestCase
  def self.it desc = "anonymous", &block
    block ||= proc { skip "(no tests defined)" }

    @specs ||= 0
    @specs += 1

    # regexp /\W+/ replaced with /\s+/
    name = "test_%04d_%s" % [ @specs, desc.gsub(/\s+/, '_').downcase ]

    define_method name, &block

    self.children.each do |mod|
      mod.send :undef_method, name if mod.public_method_defined? name
    end
  end
end

describe "test" do
  it "α β γ δ & a b c D" do
    (1+1).must_equal 3
  end
end

#   1) Failure:
# test_0001_α_β_γ_δ_&_a_b_c_d(test) [forwarding.rb:24]:
# Expected: 3
#   Actual: 2
编码:utf-8 需要“小型测试/规格” 需要“微型测试/自动运行” 类MiniTest::Spec否决并投票关闭。这不是一个问题,这是一个咆哮。咆哮属于博客,提问也是如此。这是一个问题。我想问,失败时如何返回所有unicode字母description@Jörg W Mittag我更新了我的问题,使之更加清晰