cryx-g5k 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 0
@@ -16,13 +16,16 @@ module G5K
16
16
  parser = options.delete(:parser)
17
17
  format = options.delete(:format) || params[:format] || "txt"
18
18
  body = {:code => (options[:code] || http_status), :message => options[:message], :title => options[:title]}
19
+ if defined?(::Sinatra::Application.logger)
20
+ ::Sinatra::Application.logger.error(body.inspect)
21
+ end
19
22
  content_type format.to_sym, :charset => 'utf-8'
20
23
  if (parser)
21
24
  body = parser.dump(body)
22
25
  else
23
26
  body = body.map{|(k,v)| [k,v].join("=")}.sort.join(";")
24
27
  end
25
- error(http_status, body)
28
+ throw :halt, [http_status, body]
26
29
  end
27
30
 
28
31
  def compute_etag(*differentiators)
@@ -27,7 +27,7 @@ describe G5K::Sinatra::Helpers do
27
27
  options = {:code => 500, :message => "message", :title => "title"}
28
28
  req = Request.new
29
29
  req.should_receive(:content_type).with(:json, :charset => 'utf-8')
30
- req.should_receive(:error).with(404, options.to_json)
30
+ req.should_receive(:throw).with(:halt, [404, options.to_json])
31
31
  req.formatted_error(404, options.merge({:parser => JSON, :format => 'json'}))
32
32
  end
33
33
 
@@ -35,7 +35,22 @@ describe G5K::Sinatra::Helpers do
35
35
  options = {:code => 500, :message => "message", :title => "title"}
36
36
  req = Request.new
37
37
  req.should_receive(:content_type).with(:txt, :charset => 'utf-8')
38
- req.should_receive(:error).with(404, "code=500;message=message;title=title")
38
+ req.should_receive(:throw).with(:halt, [404, "code=500;message=message;title=title"])
39
+ req.formatted_error(404, options)
40
+ end
41
+
42
+ it "should log the error if a logger is defined in the Sinatra options" do
43
+ options = {:code => 500, :message => "message", :title => "title"}
44
+ module Sinatra
45
+ module Application
46
+ end
47
+ end
48
+ logger = mock('logger')
49
+ req = Request.new
50
+ req.stub!(:content_type)
51
+ req.stub!(:throw)
52
+ Sinatra::Application.should_receive(:logger).and_return(logger)
53
+ logger.should_receive(:error).with(options.inspect)
39
54
  req.formatted_error(404, options)
40
55
  end
41
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryx-g5k
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Rohr
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-03 00:00:00 -08:00
12
+ date: 2009-03-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15