add some test
This commit is contained in:
parent
2d8a32478c
commit
02b7393ed4
1
Gemfile
1
Gemfile
@ -65,4 +65,5 @@ group :test do
|
||||
gem "capybara"
|
||||
gem "selenium-webdriver"
|
||||
gem "minitest-reporters"
|
||||
gem "rails-controller-testing"
|
||||
end
|
||||
|
@ -272,6 +272,10 @@ GEM
|
||||
activesupport (= 8.0.1)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 8.0.1)
|
||||
rails-controller-testing (1.0.5)
|
||||
actionpack (>= 5.0.1.rc1)
|
||||
actionview (>= 5.0.1.rc1)
|
||||
activesupport (>= 5.0.1.rc1)
|
||||
rails-dom-testing (2.2.0)
|
||||
activesupport (>= 5.0.0)
|
||||
minitest
|
||||
@ -443,6 +447,7 @@ DEPENDENCIES
|
||||
propshaft
|
||||
puma (>= 5.0)
|
||||
rails (~> 8.0.1)
|
||||
rails-controller-testing
|
||||
rubocop-rails-omakase
|
||||
sassc-rails (>= 2.1.0)
|
||||
selenium-webdriver
|
||||
|
@ -5,8 +5,8 @@
|
||||
</small>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><%= link_to "About", '#' %></li>
|
||||
<li><%= link_to "Contact", '#' %></li>
|
||||
<li><%= link_to "About", about_url %></li>
|
||||
<li><%= link_to "Contact", contact_url %></li>
|
||||
<li><a href="https://news.railstutorial.org">News</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<header class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="container">
|
||||
<%= link_to "sample app", '#', id: "logo" %>
|
||||
<%= link_to "sample app", root_url, id: "logo" %>
|
||||
<nav>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><%= link_to "Home", '#' %></li>
|
||||
<li><%= link_to "Help", '#' %></li>
|
||||
<li><%= link_to "Home", root_url %></li>
|
||||
<li><%= link_to "Help", help_url %></li>
|
||||
<li><%= link_to "Login in", '#' %></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -4,6 +4,10 @@ Rails.application.routes.draw do
|
||||
get "static_pages/about"
|
||||
get "static_pages/contact"
|
||||
|
||||
get '/help', to: 'static_pages#help'
|
||||
get '/about', to: 'static_pages#about'
|
||||
get '/contact', to: 'static_pages#contact'
|
||||
|
||||
root "static_pages#home"
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
|
@ -7,31 +7,25 @@ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "should get root" do
|
||||
get root_url
|
||||
assert_response :success
|
||||
assert_select "title", "Home | #{@base_title}"
|
||||
end
|
||||
|
||||
test "should get home" do
|
||||
get static_pages_home_url
|
||||
get root_path
|
||||
assert_response :success
|
||||
assert_select "title", "Home | #{@base_title}"
|
||||
end
|
||||
|
||||
test "should get help" do
|
||||
get static_pages_help_url
|
||||
get help_path
|
||||
assert_response :success
|
||||
assert_select "title", "Help | #{@base_title}"
|
||||
end
|
||||
|
||||
test "Should get about" do
|
||||
get static_pages_about_url
|
||||
get about_path
|
||||
assert_response :success
|
||||
assert_select "title", "About | #{@base_title}"
|
||||
end
|
||||
|
||||
test "Should get contact" do
|
||||
get static_pages_contact_url
|
||||
get contact_path
|
||||
assert_response :success
|
||||
assert_select "title", "Contact | #{@base_title}"
|
||||
end
|
||||
|
8
test/helpers/application_helper_test.rb
Normal file
8
test/helpers/application_helper_test.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplicationHelperTest < ActionView::TestCase
|
||||
test "full title helper" do
|
||||
assert_equal full_title, "Ruby on Rails Tutorial Sample App"
|
||||
assert_equal full_title("Contact"), "Contact | Ruby on Rails Tutorial Sample App"
|
||||
end
|
||||
end
|
15
test/integration/site_layout_test.rb
Normal file
15
test/integration/site_layout_test.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require "test_helper"
|
||||
|
||||
class SiteLayoutTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
test "layout links" do
|
||||
get root_path
|
||||
assert_template 'static_pages/home'
|
||||
assert_select "a[href=?]", root_url, count: 2
|
||||
assert_select "a[href=?]", about_url
|
||||
assert_select "a[href=?]", help_url
|
||||
assert_select "a[href=?]", contact_url
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user