如何解决Rails RSpec功能规范:使用I18n的语言环境的正确路径
我正在以3种语言(http://www.laclaveciniste.com/)为小型网站编写RSpec功能规范。对于\<:locale>\<page>
格式的路由,路由设置是一致的,例如\en\schedule
。
RSpec.feature "Basic operation of StaticPages",type: :feature do
scenario "schedule page is available" do
visit root_path
click_link "Schedule"
expect(current_path).to eq schedule_path(:locale => :en)
# further tests...
end
end
该方案失败,因为schedule_path
帮助程序未以正确的格式生成路由:
Failures:
1) Basic operation of StaticPages schedule page is available
Failure/Error: expect(current_path).to eq schedule_path(:locale => :en)
expected: "/schedule?locale=en"
got: "/en/schedule"
(compared using ==)
# ./spec/features/static_pages_spec.rb:23:in `block (2 levels) in <top (required)>'
问题:是否存在使用路径帮助器以正确格式获取URL的正确方法?我可以通过写expect(current_path).to eq "/en/schedule"
来解决问题,但我希望使用更干净的选项。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。