返回奇数结果的测试语法

问题描述

以下三个测试过程,但给出了误导性的结果,其中应用程序的认语言环境是 :en

  test "locale signed in wrong" do
    sign_in users(:end_consumer_email)
puts users(:end_consumer_email).idiom.label.downcase
    I18n.locale = users(:end_consumer_email).idiom.label.downcase
puts I18n.locale
    assert I18n.locale != 'en'
  end

  test "locale signed in correct" do
    sign_in users(:end_consumer_email)
puts users(:end_consumer_email).idiom.label.downcase.to_s
    I18n.locale = users(:end_consumer_email).idiom.label.downcase
puts I18n.locale
    assert I18n.locale == 'es'
  end

  test "locale not signed in" do
puts I18n.locale
    assert I18n.locale == 'en'
  end

第一种情况放置 es es 并返回 true。但这是海市蜃楼。 由于第二个测试返回相同的 es es 放置,但抱怨 Expected false to be truthy. 第三个测试返回 en,但同样抱怨 false 为真?

因此,在日志记录和测试的实际处理之间存在一些不正确且极具误导性的内容。 Rails 6.1.3,gem capybara 安装在测试块中,但 minitest 也作为依赖项安装。

这些测试的语法有什么错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)