Skip to content

Commit 98cdc73

Browse files
committed
add static pages and rspec
3.1静的ページ 3.2.1テスト駆動開発
1 parent 58b8cdc commit 98cdc73

File tree

9 files changed

+46
-0
lines changed

9 files changed

+46
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the StaticPages controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class StaticPagesController < ApplicationController
2+
def home
3+
end
4+
5+
def help
6+
end
7+
end

app/helpers/static_pages_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module StaticPagesHelper
2+
end

app/views/static_pages/help.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Help</h1>
2+
<p>Find me in app/views/static_pages/help.html.erb</p>

app/views/static_pages/home.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1>Sample App</h1>
2+
<p>
3+
This is the home page for the
4+
<a href="http://railstutorial.jp/">Ruby on Rails Tutorial</a>
5+
sample application.
6+
</p>

config/routes.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
Rails.application.routes.draw do
2+
get 'static_pages/home'
3+
4+
get 'static_pages/help'
5+
26
# The priority is based upon order of creation: first created -> highest priority.
37
# See how all your routes lay out with "rake routes".
48

spec/requests/static_pages_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe "StaticPages" do
4+
describe "Home page" do
5+
it "should have the content 'Sample App' " do
6+
visit '/static_pages/home'
7+
expect(page).to have_content('Sample App')
8+
end
9+
end
10+
11+
describe "Help page" do
12+
it "should have the content 'Help' " do
13+
visit '/static_pages/help'
14+
expect(page).to have_content('Help')
15+
end
16+
end
17+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@
3939
# the seed, which is printed after each run.
4040
# --seed 1234
4141
config.order = "random"
42+
43+
config.include Capybara::DSL
4244
end

0 commit comments

Comments
 (0)