Commit 13dadb1d by Tô Ngọc Ánh

Finish static pages

parent 4bcf8b09
...@@ -4,4 +4,7 @@ class StaticPagesController < ApplicationController ...@@ -4,4 +4,7 @@ class StaticPagesController < ApplicationController
def help def help
end end
def about
end
end end
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
<title>SampleApp</title> <title>SampleApp</title>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= csp_meta_tag %> <%= csp_meta_tag %>
......
<% provide(:title, 'About Us') %>
<h1>About Us</h1>
<p>
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
is a project to make a book and screencasts to teach web development
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
is the sample application for the tutorial.
</p>
\ No newline at end of file
<h1>StaticPages#help</h1> <% provide(:title, 'Help') %>
<p>Find me in app/views/static_pages/help.html.erb</p> <h1>Help</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
To get help on this sample app, see the
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
</p>
\ No newline at end of file
<h1>StaticPages#home</h1> <% provide(:title, 'Home') %>
<p>Find me in app/views/static_pages/home.html.erb</p> <h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
\ No newline at end of file
Rails.application.routes.draw do Rails.application.routes.draw do
get 'static_pages/home' get 'static_pages/home'
get 'static_pages/help' get 'static_pages/help'
get 'static_pages/about'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end end
...@@ -5,6 +5,7 @@ require File.expand_path('../config/environment', __dir__) ...@@ -5,6 +5,7 @@ require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production # Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production? abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails' require 'rspec/rails'
require 'capybara'
# Add additional requires below this line. Rails is not loaded until this point! # Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in # Requires supporting ruby files with custom matchers and macros, etc, in
...@@ -33,7 +34,7 @@ end ...@@ -33,7 +34,7 @@ end
RSpec.configure do |config| RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures" config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include Capybara::DSL
# If you're not using ActiveRecord, or you'd prefer not to run each of your # If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false # examples within a transaction, remove the following line or assign false
# instead of true. # instead of true.
......
# require 'rails_helper'
# RSpec.describe "StaticPages", type: :request do
# describe "GET /static_pages/home" do
# it "works! (now write some real specs)" do
# get static_pages_home_path
# expect(response).to have_http_status(200)
# end
# end
# end
require 'rails_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
it "should have the right title" do
visit '/static_pages/home'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Home")
end
end
describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
expect(page).to have_content('Help')
end
it "should have the title 'Help'" do
visit '/static_pages/help'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Help")
end
end
describe "About page" do
it "should have the content 'About Us'" do
visit '/static_pages/about'
expect(page).to have_content('About Us')
end
it "should have the title 'About Us'" do
visit '/static_pages/about'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | About Us")
end
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment