如何解决返回奇数结果的测试语法
以下三个测试过程,但给出了误导性的结果,其中应用程序的默认语言环境是 :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 举报,一经查实,本站将立刻删除。