diff --git a/lib/ayashige/application.rb b/lib/ayashige/application.rb index cd9057a..2a6a710 100644 --- a/lib/ayashige/application.rb +++ b/lib/ayashige/application.rb @@ -32,5 +32,9 @@ class Application < Sinatra::Base [item[:updated_on], item[:domain]] end.to_json end + + not_found do + redirect "/" + end end end diff --git a/spec/application_spec.rb b/spec/application_spec.rb index 74258dd..a723938 100644 --- a/spec/application_spec.rb +++ b/spec/application_spec.rb @@ -11,7 +11,7 @@ def app end describe "GET /" do - it "should return 200 OK" do + it "returns 200 OK" do get "/" expect(last_response).to be_ok end @@ -25,7 +25,7 @@ def app ) end - it "should return 200 OK and JSON response" do + it "returns 200 OK and JSON response" do get "/feed" expect(last_response).to be_ok array = JSON.parse(last_response.body.to_s) @@ -44,4 +44,12 @@ def app expect(last["source"]).to be_a(String) end end + + describe "GET /404" do + it "redirects to the root" do + get "/404" + expect(last_response.status).to eq(302) + expect(last_response.headers["Location"]).to eq("http://example.org/") + end + end end