在test/controllers/static_pages_controller_test.rb
中
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get static_pages_home_url
assert_response :success #检测他的请求是不是成功了。
assert_select "title", "Home | Ruby on Rails Tutorial Sample App" #测试是不是有这个标签
end
test "should get help" do
get static_pages_help_url
assert_response :success
assert_select "title", " Help | Ruby on Rails Tutorial Sample App"
end
test "should get about" do
get static_pages_about_url
assert_response :success
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
end
end
测试rails test