From b80a079f04b8d3971a3f164809dcaf1e4ed452f6 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 3 Sep 2019 17:19:58 +0100 Subject: [PATCH] Add about page Adds the about page to the demo site plus splits the unit tests so the check for a response and the check of the status code are distinct. --- lib/quke/demo_app/app.rb | 5 +++++ lib/quke/demo_app/views/about.erb | 2 ++ spec/quke/demo_app/app_spec.rb | 29 +++++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 lib/quke/demo_app/views/about.erb diff --git a/lib/quke/demo_app/app.rb b/lib/quke/demo_app/app.rb index 626814e..6724505 100644 --- a/lib/quke/demo_app/app.rb +++ b/lib/quke/demo_app/app.rb @@ -18,6 +18,11 @@ class App < Sinatra::Base @title = "Welcome to Quke" erb :index end + + get "/about" do + @title = "About" + erb :about + end end end end diff --git a/lib/quke/demo_app/views/about.erb b/lib/quke/demo_app/views/about.erb new file mode 100644 index 0000000..5044660 --- /dev/null +++ b/lib/quke/demo_app/views/about.erb @@ -0,0 +1,2 @@ +

<%= @title %>

+

The about page.

diff --git a/spec/quke/demo_app/app_spec.rb b/spec/quke/demo_app/app_spec.rb index 62a5bad..8e9a4b9 100644 --- a/spec/quke/demo_app/app_spec.rb +++ b/spec/quke/demo_app/app_spec.rb @@ -5,11 +5,32 @@ module Quke module DemoApp RSpec.describe App do - it "should allow accessing the home page" do - get "/" + context "/" do + it "GET displays the page" do + get "/" - expect(last_response).to be_ok - expect(last_response.body).to include("Welcome to Quke") + expect(last_response.body).to include("Welcome to Quke") + end + + it "GET returns the status 200" do + get "/" + + expect(last_response).to be_ok + end + end + + context "/about" do + it "GET displays the page" do + get "/" + + expect(last_response.body).to include("About") + end + + it "GET returns the status 200" do + get "/" + + expect(last_response).to be_ok + end end end end