summaryrefslogtreecommitdiff
path: root/test/error.rb
blob: 529a3bb0b985d318134f2c27abdcf646dab55890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require_relative "setup.rb"

class ErrorTest < MiniTest::Test

  def test_bad_request
    object = OpenTox::Feature.new 
    p object.id
    #TODO
    #assert_raises OpenTox::ResourceNotFoundError do
    assert_raises Mongoid::Errors::DocumentNotFound do
      response = OpenTox::Feature.find(object.id)
    end
  end

  def test_error_methods
    assert_raises OpenTox::ResourceNotFoundError do
      resource_not_found_error "This is a test"
    end
  end

  def test_exception
    assert_raises Exception do
      raise Exception.new "Basic Exception"
    end
  end

  def test_backtick
    assert_raises OpenTox::InternalServerError do
      `this call will not work`
    end
    assert_raises OpenTox::InternalServerError do
      `ls inexisting_directory`
    end
  end

end