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
.
I just want to check here:
- do visit and current_path come from capybara, whereas get comes from rack?
- does the current_path object necessarily require you to use the visit method, in order to keep it updated?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…