I want to test whether
I wrote this in my routes.rb
root :to => "pages#home"
and wrote this test in my test/functionals.
require 'test_helper'
class PagesControllerTest < ActionController::TestCase
def test_home_page
get :home
assert_response :success
end
end
And it returned success. But actually, this test cases tests the actual controller and not the home page root route and its success. How else can I get my required tests? please help.
You can create routing test in spec/routing/pages_controller_routing_spec. In rspec:
require 'spec_helper'
describe PagesController do
describe "routing" do
it "properly generates a root route to display the home page when supplying: '/'" do
{ get: "/" }.should route_to("pages#home")
end
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.