kastner (owner)

Revisions

gist: 136165 Download_button fork
public
Public Clone URL: git://gist.github.com/136165.git
books_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
class BooksController < ApplicationController
  rescue_from ActiveRecord::RecordNotFound, :with => :book_not_found
  
  def show
    @book = Book.find(params[:id])
  end
 
  def book_not_found
    render :text => "That book is not found"
  end
end
 
books_controller_test.rb
1
2
3
4
5
6
7
8
9
10
require 'test_helper'
 
class BooksControllerTest < ActionController::TestCase
  test "should catch the error" do
    assert_nothing_raised do
      get :show, :id => 123
    end
  end
end