Skip to content

Commit

Permalink
Simple crash test controller
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoDelAssembly committed Nov 11, 2014
1 parent 0e52ba6 commit 4502de3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/crash_test_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class CrashTestController < ApplicationController
def index
1/0
end
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@

# API STUB
get '/api/v1/taxon_names/' => 'api/v1/taxon_names#all'

get '/crash_test/' => 'crash_test#index' unless Rails.env.production?

# Example of regular route:
# get 'products/:id' => 'catalog#view'
Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/crash_test_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'rails_helper'

RSpec.describe CrashTestController, :type => :controller do
describe "#index" do
it "crashes when visited" do
expect { get(:index) }.to raise_error(ZeroDivisionError)
end

end

end
20 changes: 20 additions & 0 deletions spec/routing/crash_test_routing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "rails_helper"

describe CrashTestController, :type => :routing do
describe "routing" do
context "when in production" do
# before { Rails.stub_chain(:env, :production?) { true } }
it "is not routable", skip: "config/routes.rb evaluated too early. Re-evaluation possible?" do
expect(get("/crash_test")).to_not be_routable
end
end

context "when not in production" do
it "routes to #index" do
expect(get("/crash_test")).to route_to("crash_test#index")
end
end

end

end

0 comments on commit 4502de3

Please sign in to comment.