I use capybara to write feature specifications.
class UserController <ApplicationController
def index
redirect_to new_user_path
end
def new
# something
end
end
If there is a controller called
feature "sample features",:type=>:feature do
scenario "Transition to new user creation screen" do
visit users_path
expect(current_path).to eq new_user_path
end
end
As mentioned above, I would like to verify that you have been redirected to the redirect destination page after some event. Is there any way?
ruby-on-rails rspec
I think you can write an example like the following.
If you click on visit as you like, you can change it to a method that moves you.
feature "sample features",:type=>:feature do
scenario "Transition to new user creation screen" do
visit users_path
expect {visit new_user_path}.to change {
current_path
}.from(users_path).to(users_path)
end
end
© 2024 OneMinuteCode. All rights reserved.