grape 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grape might be problematic. Click here for more details.

Files changed (40) hide show
  1. data/CHANGELOG.markdown +17 -3
  2. data/Gemfile +1 -1
  3. data/README.markdown +269 -171
  4. data/grape.gemspec +1 -0
  5. data/lib/grape.rb +43 -22
  6. data/lib/grape/api.rb +7 -4
  7. data/lib/grape/endpoint.rb +48 -9
  8. data/lib/grape/entity.rb +1 -1
  9. data/lib/grape/error_formatter/base.rb +32 -0
  10. data/lib/grape/error_formatter/json.rb +17 -0
  11. data/lib/grape/error_formatter/txt.rb +18 -0
  12. data/lib/grape/error_formatter/xml.rb +17 -0
  13. data/lib/grape/exceptions/validation_error.rb +9 -5
  14. data/lib/grape/formatter/base.rb +33 -0
  15. data/lib/grape/formatter/json.rb +15 -0
  16. data/lib/grape/formatter/serializable_hash.rb +35 -0
  17. data/lib/grape/formatter/txt.rb +13 -0
  18. data/lib/grape/formatter/xml.rb +13 -0
  19. data/lib/grape/middleware/base.rb +18 -103
  20. data/lib/grape/middleware/error.rb +16 -32
  21. data/lib/grape/middleware/formatter.rb +8 -9
  22. data/lib/grape/middleware/versioner.rb +3 -2
  23. data/lib/grape/middleware/versioner/header.rb +1 -1
  24. data/lib/grape/parser/base.rb +31 -0
  25. data/lib/grape/parser/json.rb +13 -0
  26. data/lib/grape/parser/xml.rb +13 -0
  27. data/lib/grape/validations.rb +1 -1
  28. data/lib/grape/validations/coerce.rb +1 -1
  29. data/lib/grape/validations/presence.rb +1 -1
  30. data/lib/grape/validations/regexp.rb +1 -1
  31. data/lib/grape/version.rb +1 -1
  32. data/spec/grape/api_spec.rb +183 -9
  33. data/spec/grape/endpoint_spec.rb +27 -1
  34. data/spec/grape/entity_spec.rb +21 -21
  35. data/spec/grape/middleware/base_spec.rb +15 -15
  36. data/spec/grape/middleware/exception_spec.rb +38 -16
  37. data/spec/grape/middleware/formatter_spec.rb +6 -40
  38. data/spec/grape/validations/presence_spec.rb +20 -20
  39. data/spec/spec_helper.rb +1 -1
  40. metadata +132 -58
@@ -293,7 +293,7 @@ describe Grape::Endpoint do
293
293
  last_response.body.should == '{"dude":"rad"}'
294
294
  end
295
295
  end
296
-
296
+
297
297
  describe "#redirect" do
298
298
  it "should redirect to a url with status 302" do
299
299
  subject.get('/hey') do
@@ -354,6 +354,32 @@ describe Grape::Endpoint do
354
354
  last_response.body.should == 'yo'
355
355
  end
356
356
 
357
+ it 'should allow explicit return calls' do
358
+ subject.get('/home') do
359
+ return "Hello"
360
+ end
361
+
362
+ get '/home'
363
+ last_response.status.should == 200
364
+ last_response.body.should == "Hello"
365
+ end
366
+
367
+ describe ".generate_api_method" do
368
+ it "should raise NameError if the method name is already in use" do
369
+ expect {
370
+ Grape::Endpoint.generate_api_method("version", &proc{})
371
+ }.to raise_error(NameError)
372
+ end
373
+ it "should raise ArgumentError if a block is not given" do
374
+ expect {
375
+ Grape::Endpoint.generate_api_method("GET without a block method")
376
+ }.to raise_error(ArgumentError)
377
+ end
378
+ it "should return a Proc" do
379
+ Grape::Endpoint.generate_api_method("GET test for a proc", &proc{}).should be_a Proc
380
+ end
381
+ end
382
+
357
383
  describe '#present' do
358
384
  it 'should just set the object as the body if no options are provided' do
359
385
  subject.get '/example' do
@@ -26,7 +26,7 @@ describe Grape::Entity do
26
26
  end
27
27
 
28
28
  it 'should make sure that :format_with as a proc can not be used with a block' do
29
- expect { subject.expose :name, :format_with => Proc.new {} do |object,options| end }.to raise_error(ArgumentError)
29
+ expect { subject.expose :name, :format_with => Proc.new {} do |_| end }.to raise_error(ArgumentError)
30
30
  end
31
31
  end
32
32
 
@@ -38,7 +38,7 @@ describe Grape::Entity do
38
38
  end
39
39
 
40
40
  it 'should set the :proc option in the exposure options' do
41
- block = lambda{|obj,opts| true }
41
+ block = lambda{|_| true }
42
42
  subject.expose :name, &block
43
43
  subject.exposures[:name][:proc].should == block
44
44
  end
@@ -60,10 +60,10 @@ describe Grape::Entity do
60
60
  child_class.exposures.should eq(subject.exposures)
61
61
  end
62
62
 
63
- it 'should return descendant exposures as a priotity' do
63
+ it 'should return descendant exposures as a priority' do
64
64
  subject.expose :name, :email
65
65
  child_class = Class.new(subject)
66
- child_class.expose :name do |n|
66
+ child_class.expose :name do |_|
67
67
  'foo'
68
68
  end
69
69
 
@@ -263,48 +263,48 @@ describe Grape::Entity do
263
263
  end
264
264
 
265
265
  it 'should not throw an exception when an attribute is not found on the object' do
266
- fresh_class.expose :name, :non_existant_attribute
266
+ fresh_class.expose :name, :nonexistent_attribute
267
267
  expect{ fresh_class.new(model).serializable_hash }.not_to raise_error
268
268
  end
269
269
 
270
270
  it "should not expose attributes that don't exist on the object" do
271
- fresh_class.expose :email, :non_existant_attribute, :name
271
+ fresh_class.expose :email, :nonexistent_attribute, :name
272
272
 
273
273
  res = fresh_class.new(model).serializable_hash
274
274
  res.should have_key :email
275
- res.should_not have_key :non_existant_attribute
275
+ res.should_not have_key :nonexistent_attribute
276
276
  res.should have_key :name
277
277
  end
278
278
 
279
279
  it "should not expose attributes that don't exist on the object, even with criteria" do
280
280
  fresh_class.expose :email
281
- fresh_class.expose :non_existant_attribute, :if => lambda { false }
282
- fresh_class.expose :non_existant_attribute2, :if => lambda { true }
281
+ fresh_class.expose :nonexistent_attribute, :if => lambda { false }
282
+ fresh_class.expose :nonexistent_attribute2, :if => lambda { true }
283
283
 
284
284
  res = fresh_class.new(model).serializable_hash
285
285
  res.should have_key :email
286
- res.should_not have_key :non_existant_attribute
287
- res.should_not have_key :non_existant_attribute2
286
+ res.should_not have_key :nonexistent_attribute
287
+ res.should_not have_key :nonexistent_attribute2
288
288
  end
289
289
 
290
290
  it "should expose attributes that don't exist on the object only when they are generated by a block" do
291
- fresh_class.expose :non_existant_attribute do |model, options|
291
+ fresh_class.expose :nonexistent_attribute do |model, _|
292
292
  "well, I do exist after all"
293
293
  end
294
294
  res = fresh_class.new(model).serializable_hash
295
- res.should have_key :non_existant_attribute
295
+ res.should have_key :nonexistent_attribute
296
296
  end
297
297
 
298
298
  it "should not expose attributes that are generated by a block but have not passed criteria" do
299
- fresh_class.expose :non_existant_attribute, :proc => lambda {|model, options|
299
+ fresh_class.expose :nonexistent_attribute, :proc => lambda {|model, _|
300
300
  "I exist, but it is not yet my time to shine"
301
- }, :if => lambda { |model, options| false }
301
+ }, :if => lambda { |model, _| false }
302
302
  res = fresh_class.new(model).serializable_hash
303
- res.should_not have_key :non_existant_attribute
303
+ res.should_not have_key :nonexistent_attribute
304
304
  end
305
-
305
+
306
306
  context "#serializable_hash" do
307
-
307
+
308
308
  module EntitySpec
309
309
  class EmbeddedExample
310
310
  def serializable_hash(opts = {})
@@ -350,7 +350,7 @@ describe Grape::Entity do
350
350
  fresh_class.class_eval do
351
351
  expose :name, :email
352
352
  expose :friends, :using => self
353
- expose :computed do |object, options|
353
+ expose :computed do |_, options|
354
354
  options[:awesome]
355
355
  end
356
356
 
@@ -503,7 +503,7 @@ describe Grape::Entity do
503
503
  end
504
504
 
505
505
  it 'should only pass through proc :if exposure if it returns truthy value' do
506
- exposure_options = {:if => lambda{|obj,opts| opts[:true]}}
506
+ exposure_options = {:if => lambda{|_,opts| opts[:true]}}
507
507
 
508
508
  subject.send(:conditions_met?, exposure_options, :true => false).should be_false
509
509
  subject.send(:conditions_met?, exposure_options, :true => true).should be_true
@@ -521,7 +521,7 @@ describe Grape::Entity do
521
521
  end
522
522
 
523
523
  it 'should only pass through proc :unless exposure if it returns falsy value' do
524
- exposure_options = {:unless => lambda{|object,options| options[:true] == true}}
524
+ exposure_options = {:unless => lambda{|_,options| options[:true] == true}}
525
525
 
526
526
  subject.send(:conditions_met?, exposure_options, :true => false).should be_true
527
527
  subject.send(:conditions_met?, exposure_options, :true => true).should be_false
@@ -1,63 +1,63 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Grape::Middleware::Base do
4
- subject { Grape::Middleware::Base.new(blank_app) }
5
- let(:blank_app) { lambda{|env| [200, {}, 'Hi there.']} }
6
-
4
+ subject { Grape::Middleware::Base.new( blank_app) }
5
+ let(:blank_app) { lambda{|_| [200, {}, 'Hi there.']} }
6
+
7
7
  before do
8
8
  # Keep it one object for testing.
9
9
  subject.stub!(:dup).and_return(subject)
10
10
  end
11
-
11
+
12
12
  it 'should have the app as an accessor' do
13
13
  subject.app.should == blank_app
14
14
  end
15
-
15
+
16
16
  it 'should be able to access the request' do
17
17
  subject.call({})
18
18
  subject.request.should be_kind_of(Rack::Request)
19
19
  end
20
-
20
+
21
21
  it 'should call through to the app' do
22
22
  subject.call({}).should == [200, {}, 'Hi there.']
23
23
  end
24
-
24
+
25
25
  context 'callbacks' do
26
26
  it 'should call #before' do
27
27
  subject.should_receive(:before)
28
28
  end
29
-
29
+
30
30
  it 'should call #after' do
31
31
  subject.should_receive(:after)
32
32
  end
33
-
33
+
34
34
  after{ subject.call!({}) }
35
35
  end
36
-
36
+
37
37
  it 'should be able to access the response' do
38
38
  subject.call({})
39
39
  subject.response.should be_kind_of(Rack::Response)
40
40
  end
41
-
41
+
42
42
  context 'options' do
43
43
  it 'should persist options passed at initialization' do
44
44
  Grape::Middleware::Base.new(blank_app, {:abc => true}).options[:abc].should be_true
45
45
  end
46
-
46
+
47
47
  context 'defaults' do
48
48
  class ExampleWare < Grape::Middleware::Base
49
49
  def default_options
50
50
  {:monkey => true}
51
51
  end
52
52
  end
53
-
53
+
54
54
  it 'should persist the default options' do
55
55
  ExampleWare.new(blank_app).options[:monkey].should be_true
56
56
  end
57
-
57
+
58
58
  it 'should override default options when provided' do
59
59
  ExampleWare.new(blank_app, :monkey => false).options[:monkey].should be_false
60
60
  end
61
61
  end
62
62
  end
63
- end
63
+ end
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
+ require 'active_support/core_ext/hash'
2
3
 
3
4
  describe Grape::Middleware::Error do
4
-
5
+
5
6
  # raises a text exception
6
7
  class ExceptionApp
7
8
  class << self
@@ -10,7 +11,7 @@ describe Grape::Middleware::Error do
10
11
  end
11
12
  end
12
13
  end
13
-
14
+
14
15
  # raises a hash error
15
16
  class ErrorHashApp
16
17
  class << self
@@ -22,9 +23,9 @@ describe Grape::Middleware::Error do
22
23
  end
23
24
  end
24
25
  end
25
-
26
+
26
27
  # raises an error!
27
- class AccessDeniedApp
28
+ class AccessDeniedApp
28
29
  class << self
29
30
  def error!(message, status=403)
30
31
  throw :error, :message => message, :status => status
@@ -44,11 +45,11 @@ describe Grape::Middleware::Error do
44
45
  end
45
46
  end
46
47
  end
47
-
48
+
48
49
  def app
49
50
  @app
50
51
  end
51
-
52
+
52
53
  it 'should not trap errors by default' do
53
54
  @app ||= Rack::Builder.app do
54
55
  use Grape::Middleware::Error
@@ -84,7 +85,7 @@ describe Grape::Middleware::Error do
84
85
  get '/'
85
86
  last_response.status.should == 500
86
87
  end
87
-
88
+
88
89
  it 'should be possible to return errors in json format' do
89
90
  @app ||= Rack::Builder.app do
90
91
  use Grape::Middleware::Error, :rescue_all => true, :format => :json
@@ -104,28 +105,49 @@ describe Grape::Middleware::Error do
104
105
  '{"detail":"missing widget","error":"rain!"}'].should be_include(last_response.body)
105
106
  end
106
107
 
108
+ it 'should be possible to return errors in xml format' do
109
+ @app ||= Rack::Builder.app do
110
+ use Grape::Middleware::Error, :rescue_all => true, :format => :xml
111
+ run ExceptionApp
112
+ end
113
+ get '/'
114
+ last_response.body.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n <message>rain!</message>\n</error>\n"
115
+ end
116
+
117
+ it 'should be possible to return hash errors in xml format' do
118
+ @app ||= Rack::Builder.app do
119
+ use Grape::Middleware::Error, :rescue_all => true, :format => :xml
120
+ run ErrorHashApp
121
+ end
122
+ get '/'
123
+ ["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n <detail>missing widget</detail>\n <error>rain!</error>\n</error>\n",
124
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n <error>rain!</error>\n <detail>missing widget</detail>\n</error>\n"].should be_include(last_response.body)
125
+ end
126
+
107
127
  it 'should be possible to specify a custom formatter' do
108
128
  @app ||= Rack::Builder.app do
109
- use Grape::Middleware::Error,
129
+ use Grape::Middleware::Error,
110
130
  :rescue_all => true,
111
- :format => :custom,
112
- :formatters => {
113
- :custom => lambda { |message, backtrace| { :custom_formatter => message }.inspect }
131
+ :format => :custom,
132
+ :error_formatters => {
133
+ :custom => lambda { |message, backtrace, options, env|
134
+ { :custom_formatter => message }.inspect
135
+ }
114
136
  }
115
137
  run ExceptionApp
116
138
  end
117
139
  get '/'
118
140
  last_response.body.should == '{:custom_formatter=>"rain!"}'
119
141
  end
120
-
142
+
121
143
  it 'should not trap regular error! codes' do
122
144
  @app ||= Rack::Builder.app do
123
145
  use Grape::Middleware::Error
124
146
  run AccessDeniedApp
125
147
  end
126
148
  get '/'
127
- last_response.status.should == 401
128
- end
149
+ last_response.status.should == 401
150
+ end
129
151
 
130
152
  it 'should respond to custom Grape exceptions appropriately' do
131
153
  @app ||= Rack::Builder.app do
@@ -137,6 +159,6 @@ describe Grape::Middleware::Error do
137
159
  last_response.status.should == 400
138
160
  last_response.body.should == 'failed validation'
139
161
  end
140
-
141
- end
162
+
163
+ end
142
164
  end
@@ -13,7 +13,7 @@ describe Grape::Middleware::Formatter do
13
13
  bodies.each{|b| b.should == MultiJson.dump(@body) }
14
14
  end
15
15
 
16
- it 'should call #to_json first if it is available' do
16
+ it 'should call #to_json since default format is json' do
17
17
  @body = ['foo']
18
18
  @body.instance_eval do
19
19
  def to_json
@@ -24,42 +24,6 @@ describe Grape::Middleware::Formatter do
24
24
  subject.call({'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json'}).last.each{|b| b.should == '"bar"'}
25
25
  end
26
26
 
27
- it 'should serialize the #serializable_hash if that is available' do
28
- class SimpleExample
29
- def serializable_hash
30
- {:abc => 'def'}
31
- end
32
- end
33
-
34
- @body = [SimpleExample.new, SimpleExample.new]
35
-
36
- subject.call({'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json'}).last.each{|b| b.should == '[{"abc":"def"},{"abc":"def"}]'}
37
- end
38
-
39
- it 'should serialize multiple objects that respond to #serializable_hash' do
40
- class SimpleExample
41
- def serializable_hash
42
- {:abc => 'def'}
43
- end
44
- end
45
-
46
- @body = SimpleExample.new
47
-
48
- subject.call({'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json'}).last.each{|b| b.should == '{"abc":"def"}'}
49
- end
50
-
51
- it 'should serialize objects that respond to #serializable_hash if there is a root element' do
52
- class SimpleExample
53
- def serializable_hash
54
- {:abc => 'def'}
55
- end
56
- end
57
-
58
- @body = {"root" => SimpleExample.new}
59
-
60
- subject.call({'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json'}).last.each{|b| b.should == '{"root":{"abc":"def"}}'}
61
- end
62
-
63
27
  it 'should call #to_xml if the content type is xml' do
64
28
  @body = "string"
65
29
  @body.instance_eval do
@@ -80,7 +44,7 @@ describe Grape::Middleware::Formatter do
80
44
  subject.env['api.format'].should == :json
81
45
  end
82
46
 
83
- it 'should use the format parameter if one is provided' do
47
+ it 'should use the format parameter if one is provided' do
84
48
  subject.call({'PATH_INFO' => '/somewhere','QUERY_STRING' => 'format=json'})
85
49
  subject.env['api.format'].should == :json
86
50
  subject.call({'PATH_INFO' => '/somewhere','QUERY_STRING' => 'format=xml'})
@@ -156,6 +120,7 @@ describe Grape::Middleware::Formatter do
156
120
  headers['Content-type'].should == 'text/plain'
157
121
  end
158
122
  it 'should be set for custom' do
123
+ subject.options[:content_types] = {}
159
124
  subject.options[:content_types][:custom] = 'application/x-custom'
160
125
  _, headers, _ = subject.call({'PATH_INFO' => '/info.custom'})
161
126
  headers['Content-type'].should == 'application/x-custom'
@@ -164,8 +129,9 @@ describe Grape::Middleware::Formatter do
164
129
 
165
130
  context 'Format' do
166
131
  it 'should use custom formatter' do
132
+ subject.options[:content_types] = {}
167
133
  subject.options[:content_types][:custom] = "don't care"
168
- subject.options[:formatters][:custom] = lambda { |obj| 'CUSTOM FORMAT' }
134
+ subject.options[:formatters][:custom] = lambda { |obj, env| 'CUSTOM FORMAT' }
169
135
  _, _, body = subject.call({'PATH_INFO' => '/info.custom'})
170
136
  body.body.should == ['CUSTOM FORMAT']
171
137
  end
@@ -175,7 +141,7 @@ describe Grape::Middleware::Formatter do
175
141
  body.body.should == ['["blah"]']
176
142
  end
177
143
  it 'should use custom json formatter' do
178
- subject.options[:formatters][:json] = lambda { |obj| 'CUSTOM JSON FORMAT' }
144
+ subject.options[:formatters][:json] = lambda { |obj, env| 'CUSTOM JSON FORMAT' }
179
145
  _, _, body = subject.call({'PATH_INFO' => '/info.json'})
180
146
  body.body.should == ['CUSTOM JSON FORMAT']
181
147
  end
@@ -19,7 +19,7 @@ describe Grape::Validations::PresenceValidator do
19
19
  post do
20
20
  {:ret => params[:id]}
21
21
  end
22
-
22
+
23
23
  params do
24
24
  requires :name, :company
25
25
  end
@@ -52,7 +52,7 @@ describe Grape::Validations::PresenceValidator do
52
52
  end
53
53
  end
54
54
  end
55
-
55
+
56
56
  def app
57
57
  ValidationsSpec::PresenceValidatorSpec::API
58
58
  end
@@ -62,30 +62,30 @@ describe Grape::Validations::PresenceValidator do
62
62
  last_response.status.should == 200
63
63
  last_response.body.should == "All the bacon"
64
64
  end
65
-
65
+
66
66
  it 'validates id' do
67
67
  post('/')
68
68
  last_response.status.should == 400
69
- last_response.body.should == "missing parameter: id"
70
-
69
+ last_response.body.should == '{"error":"missing parameter: id"}'
70
+
71
71
  post('/', {}, 'rack.input' => StringIO.new('{"id" : "a56b"}'))
72
- last_response.body.should == 'invalid parameter: id'
72
+ last_response.body.should == '{"error":"invalid parameter: id"}'
73
73
  last_response.status.should == 400
74
-
74
+
75
75
  post('/', {}, 'rack.input' => StringIO.new('{"id" : 56}'))
76
76
  last_response.body.should == '{"ret":56}'
77
77
  last_response.status.should == 201
78
78
  end
79
-
79
+
80
80
  it 'validates name, company' do
81
81
  get('/')
82
82
  last_response.status.should == 400
83
- last_response.body.should == "missing parameter: name"
84
-
83
+ last_response.body.should == '{"error":"missing parameter: name"}'
84
+
85
85
  get('/', :name => "Bob")
86
86
  last_response.status.should == 400
87
- last_response.body.should == "missing parameter: company"
88
-
87
+ last_response.body.should == '{"error":"missing parameter: company"}'
88
+
89
89
  get('/', :name => "Bob", :company => "TestCorp")
90
90
  last_response.status.should == 200
91
91
  last_response.body.should == "Hello"
@@ -94,11 +94,11 @@ describe Grape::Validations::PresenceValidator do
94
94
  it 'validates nested parameters' do
95
95
  get('/nested')
96
96
  last_response.status.should == 400
97
- last_response.body.should == "missing parameter: first_name"
97
+ last_response.body.should == '{"error":"missing parameter: first_name"}'
98
98
 
99
99
  get('/nested', :user => {:first_name => "Billy"})
100
100
  last_response.status.should == 400
101
- last_response.body.should == "missing parameter: last_name"
101
+ last_response.body.should == '{"error":"missing parameter: last_name"}'
102
102
 
103
103
  get('/nested', :user => {:first_name => "Billy", :last_name => "Bob"})
104
104
  last_response.status.should == 200
@@ -108,27 +108,27 @@ describe Grape::Validations::PresenceValidator do
108
108
  it 'validates triple nested parameters' do
109
109
  get('/nested_triple')
110
110
  last_response.status.should == 400
111
- last_response.body.should == "missing parameter: admin_name"
111
+ last_response.body.should == '{"error":"missing parameter: admin_name"}'
112
112
 
113
113
  get('/nested_triple', :user => {:first_name => "Billy"})
114
114
  last_response.status.should == 400
115
- last_response.body.should == "missing parameter: admin_name"
115
+ last_response.body.should == '{"error":"missing parameter: admin_name"}'
116
116
 
117
117
  get('/nested_triple', :admin => {:super => {:first_name => "Billy"}})
118
118
  last_response.status.should == 400
119
- last_response.body.should == "missing parameter: admin_name"
119
+ last_response.body.should == '{"error":"missing parameter: admin_name"}'
120
120
 
121
121
  get('/nested_triple', :super => {:user => {:first_name => "Billy", :last_name => "Bob"}})
122
122
  last_response.status.should == 400
123
- last_response.body.should == "missing parameter: admin_name"
123
+ last_response.body.should == '{"error":"missing parameter: admin_name"}'
124
124
 
125
125
  get('/nested_triple', :admin => {:super => {:user => {:first_name => "Billy"}}})
126
126
  last_response.status.should == 400
127
- last_response.body.should == "missing parameter: admin_name"
127
+ last_response.body.should == '{"error":"missing parameter: admin_name"}'
128
128
 
129
129
  get('/nested_triple', :admin => { :admin_name => 'admin', :super => {:user => {:first_name => "Billy"}}})
130
130
  last_response.status.should == 400
131
- last_response.body.should == "missing parameter: last_name"
131
+ last_response.body.should == '{"error":"missing parameter: last_name"}'
132
132
 
133
133
  get('/nested_triple', :admin => { :admin_name => 'admin', :super => {:user => {:first_name => "Billy", :last_name => "Bob"}}})
134
134
  last_response.status.should == 200