[英]Rspec and capybara, difference between visit and get methods, with regards to the current_path object
I'm possibly confusing rack and capybara methods here 我可能在这里混淆机架和水豚方法
let!(:admin){FactoryGirl.create(:admin)}
# test passes
describe "visiting #edit page" do
before { visit edit_user_path(admin) }
specify { current_path.should eq(edit_user_path(admin)) }
end
# test fails
describe "getting #edit page" do
before { get edit_user_path(admin) }
specify { current_path.should eq(edit_user_path(admin)) }
end
The second test fails with: 第二次测试失败了:
Failure/Error: specify { current_path.should eq(edit_user_path(admin)) }
expected: "/users/51/edit"
got: "/users/51"
(compared using ==)
A before(:each)
block, sets the current_path to /users/51
, so it looks like it remains that way when using get
. 在before(:each)
块之前,将current_path设置为/users/51
,因此在使用get
时它看起来仍然是那样。
I just want to check here: 我只想在这里查看:
Your issue is a shared issue and was described in a post by Jose Valim . 你的问题是一个共同的问题,并在Jose Valim的一篇文章中有描述 。
To be short, in integration tests, only use visit
. 简而言之,在集成测试中,只使用visit
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.