Rspec匹配当前url
要用所需的url检查当前url吗Rspec匹配当前url,rspec,Rspec,要用所需的url检查当前url吗 describe "SEO Error" do it "URL" do visit 'http://localhost:4000/' current_path.should == 'http://localhost:4000/' end end 得到的错误类似于 Failure/Error: current_path.should == 'http://localhost:4000/' expected: "htt
describe "SEO Error" do
it "URL" do
visit 'http://localhost:4000/'
current_path.should == 'http://localhost:4000/'
end
end
得到的错误类似于
Failure/Error: current_path.should == 'http://localhost:4000/'
expected: "http://localhost:4000/"
got: "/" (using ==)
有什么想法吗?根据,水豚的
当前路径不返回任何域信息。刚刚遇到了同样的问题。我自己就这样解决了:
expect(current_path).to have_content(expected_path)
请注意,自从您提出问题以来,已经过了很长时间,我现在使用的是新版rspec,它使用了expect
,而不是should
很好的答案。我认为应该交换预期路径
和当前路径
。是的,你是对的