Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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
Rspec匹配当前url_Rspec - Fatal编程技术网

Rspec匹配当前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

要用所需的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: "http://localhost:4000/"
        got: "/" (using ==)

有什么想法吗?

根据,水豚的
当前路径不返回任何域信息。

刚刚遇到了同样的问题。我自己就这样解决了:

expect(current_path).to have_content(expected_path)

请注意,自从您提出问题以来,已经过了很长时间,我现在使用的是新版rspec,它使用了
expect
,而不是
should

很好的答案。我认为应该交换
预期路径
当前路径
。是的,你是对的