therealadam (owner)

Revisions

gist: 49274 Download_button fork
public
Public Clone URL: git://gist.github.com/49274.git
Embed All Files: show embed
app.rb #
1
2
3
4
5
6
7
8
not_found do
  'Bonk'
end
 
error(ActiveRecord::RecordNotFound) do
  status(404)
  'Aside not found'
end
new_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  it 'allows changing the response status from the error handler' do
    mock_app {
      
      not_found do
        'I know exactly what that is!'
      end
      
      error FooNotFound do
        status(404)
        'I have no idea what that is'
      end
      
      get '/' do
        raise FooNotFound
      end
    }
    
    get '/'
    assert_equal 404, status
    assert_equal 'I have no idea what that is', body
  end