praxis 0.22.pre.1 → 2.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +5 -20
  3. data/CHANGELOG.md +328 -323
  4. data/lib/praxis.rb +13 -9
  5. data/lib/praxis/action_definition.rb +8 -10
  6. data/lib/praxis/action_definition/headers_dsl_compiler.rb +1 -1
  7. data/lib/praxis/api_definition.rb +27 -44
  8. data/lib/praxis/api_general_info.rb +2 -3
  9. data/lib/praxis/application.rb +15 -142
  10. data/lib/praxis/bootloader.rb +1 -2
  11. data/lib/praxis/bootloader_stages/environment.rb +13 -0
  12. data/lib/praxis/config.rb +1 -1
  13. data/lib/praxis/controller.rb +0 -2
  14. data/lib/praxis/dispatcher.rb +4 -6
  15. data/lib/praxis/docs/generator.rb +8 -18
  16. data/lib/praxis/docs/link_builder.rb +1 -1
  17. data/lib/praxis/error_handler.rb +5 -5
  18. data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +1 -1
  19. data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +1 -1
  20. data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +125 -0
  21. data/lib/praxis/extensions/field_selection.rb +1 -12
  22. data/lib/praxis/extensions/field_selection/active_record_query_selector.rb +28 -34
  23. data/lib/praxis/extensions/field_selection/sequel_query_selector.rb +35 -39
  24. data/lib/praxis/extensions/rendering.rb +1 -1
  25. data/lib/praxis/file_group.rb +1 -1
  26. data/lib/praxis/handlers/xml.rb +1 -1
  27. data/lib/praxis/mapper/active_model_compat.rb +98 -0
  28. data/lib/praxis/mapper/resource.rb +242 -0
  29. data/lib/praxis/mapper/selector_generator.rb +154 -0
  30. data/lib/praxis/mapper/sequel_compat.rb +76 -0
  31. data/lib/praxis/media_type_identifier.rb +2 -1
  32. data/lib/praxis/middleware_app.rb +13 -15
  33. data/lib/praxis/multipart/part.rb +3 -5
  34. data/lib/praxis/notifications.rb +1 -1
  35. data/lib/praxis/plugins/mapper_plugin.rb +64 -0
  36. data/lib/praxis/request.rb +14 -7
  37. data/lib/praxis/request_stages/response.rb +2 -3
  38. data/lib/praxis/resource_definition.rb +15 -19
  39. data/lib/praxis/response.rb +6 -5
  40. data/lib/praxis/response_definition.rb +5 -7
  41. data/lib/praxis/response_template.rb +3 -4
  42. data/lib/praxis/responses/http.rb +36 -0
  43. data/lib/praxis/responses/internal_server_error.rb +12 -3
  44. data/lib/praxis/responses/multipart_ok.rb +11 -4
  45. data/lib/praxis/responses/validation_error.rb +10 -1
  46. data/lib/praxis/route.rb +1 -1
  47. data/lib/praxis/router.rb +3 -3
  48. data/lib/praxis/routing_config.rb +1 -1
  49. data/lib/praxis/tasks/api_docs.rb +2 -10
  50. data/lib/praxis/tasks/routes.rb +0 -1
  51. data/lib/praxis/trait.rb +1 -1
  52. data/lib/praxis/types/media_type_common.rb +2 -2
  53. data/lib/praxis/types/multipart.rb +1 -1
  54. data/lib/praxis/types/multipart_array.rb +2 -2
  55. data/lib/praxis/types/multipart_array/part_definition.rb +1 -1
  56. data/lib/praxis/version.rb +1 -1
  57. data/praxis.gemspec +11 -9
  58. data/spec/functional_spec.rb +0 -1
  59. data/spec/praxis/action_definition_spec.rb +16 -27
  60. data/spec/praxis/api_definition_spec.rb +8 -13
  61. data/spec/praxis/api_general_info_spec.rb +8 -3
  62. data/spec/praxis/application_spec.rb +8 -14
  63. data/spec/praxis/collection_spec.rb +3 -2
  64. data/spec/praxis/config_spec.rb +2 -2
  65. data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +106 -0
  66. data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +147 -0
  67. data/spec/praxis/extensions/field_selection/support/spec_resources_active_model.rb +130 -0
  68. data/spec/praxis/extensions/field_selection/support/spec_resources_sequel.rb +106 -0
  69. data/spec/praxis/handlers/xml_spec.rb +2 -2
  70. data/spec/praxis/mapper/resource_spec.rb +169 -0
  71. data/spec/praxis/mapper/selector_generator_spec.rb +325 -0
  72. data/spec/praxis/media_type_spec.rb +0 -10
  73. data/spec/praxis/middleware_app_spec.rb +16 -10
  74. data/spec/praxis/request_spec.rb +7 -17
  75. data/spec/praxis/request_stages/action_spec.rb +8 -1
  76. data/spec/praxis/request_stages/validate_spec.rb +1 -1
  77. data/spec/praxis/resource_definition_spec.rb +10 -12
  78. data/spec/praxis/response_definition_spec.rb +12 -26
  79. data/spec/praxis/response_spec.rb +6 -13
  80. data/spec/praxis/responses/internal_server_error_spec.rb +5 -2
  81. data/spec/praxis/router_spec.rb +5 -9
  82. data/spec/spec_app/app/controllers/instances.rb +1 -1
  83. data/spec/spec_app/config.ru +6 -1
  84. data/spec/spec_app/config/environment.rb +3 -21
  85. data/spec/spec_helper.rb +13 -17
  86. data/spec/support/be_deep_equal_matcher.rb +39 -0
  87. data/spec/support/spec_resources.rb +124 -0
  88. metadata +74 -53
  89. data/lib/praxis/extensions/attribute_filtering.rb +0 -28
  90. data/lib/praxis/extensions/attribute_filtering/query_builder.rb +0 -39
  91. data/lib/praxis/extensions/mapper_selectors.rb +0 -16
  92. data/lib/praxis/media_type_collection.rb +0 -127
  93. data/lib/praxis/plugins/praxis_mapper_plugin.rb +0 -246
  94. data/spec/praxis/media_type_collection_spec.rb +0 -157
  95. data/spec/praxis/plugins/praxis_mapper_plugin_spec.rb +0 -142
  96. data/spec/spec_app/app/models/person.rb +0 -3
@@ -52,16 +52,6 @@ describe Praxis::MediaType do
52
52
  subject(:address_klass) { address.class }
53
53
 
54
54
  context '#identifier' do
55
- context 'in praxis v0' do
56
- it 'should be a kind of String' do
57
- if Praxis::VERSION =~ /^0/
58
- expect(subject.identifier).to be_kind_of(String)
59
- else
60
- raise 'Please remove this spec which is no longer pertinent'
61
- end
62
- end
63
- end
64
-
65
55
  context 'in praxis v1.0 and beyond' do
66
56
  it 'should be a kind of Praxis::MediaTypeIdentifier' do
67
57
  pending('interface-breaking change') if Praxis::VERSION =~ /^0/
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Praxis::MiddlewareApp do
4
4
 
5
- let(:init_args){ { root: 'here', name: 'middleware_app_spec', skip_registration: true} }
6
- let(:middleware) { Praxis::MiddlewareApp.for( init_args ) }
5
+ let(:init_args){ { root: 'here'} }
6
+ let(:middleware) { Praxis::MiddlewareApp.for( **init_args ) }
7
7
  let(:instance){ middleware.new(target)}
8
8
 
9
9
  context '.for' do
@@ -29,22 +29,28 @@ describe Praxis::MiddlewareApp do
29
29
  end
30
30
 
31
31
  context '.call' do
32
- let(:the_instance) { double("The instance", setup: nil) }
33
32
  let(:env){ {} }
34
33
  let(:praxis_response){ [200,{}] }
35
34
  subject(:response){ instance.call(env) }
36
35
  before do
37
36
  # always invokes the praxis app
38
- expect( Praxis::Application ).to receive(:new).once.and_return(the_instance)
39
- expect( the_instance ).to receive(:call).with( env ).once.and_return(praxis_response)
40
- allow( the_instance ).to receive(:setup).and_return(the_instance)
37
+ expect( Praxis::Application.instance ).to receive(:call).with( env ).once.and_return(praxis_response)
41
38
  end
42
39
 
43
- it 'does not explicitly call setup in the initialization (the app needs to do it at the right time)' do
44
- expect( the_instance ).to_not receive(:setup)
45
- subject
40
+ context 'when it has not been setup yet' do
41
+ it 'initializes the application singleton with the passed parameters' do
42
+ expect( Praxis::Application.instance ).to receive(:setup).with( init_args ).once
43
+ subject
44
+ end
45
+ end
46
+ context 'when it has already been setup' do
47
+ it 'does NOT call instance setup' do
48
+ middleware.setup
49
+ expect( Praxis::Application.instance ).to_not receive(:setup)
50
+ subject
51
+ end
46
52
  end
47
-
53
+
48
54
  context 'properly handled (non-404 and 405) responses from praxis' do
49
55
  it 'are returned straight through' do
50
56
  expect( response ).to be(praxis_response)
@@ -12,17 +12,7 @@ describe Praxis::Request do
12
12
  env['HTTP_AUTHORIZATION'] = 'Secret'
13
13
  env
14
14
  end
15
- let(:application) do
16
- app = Praxis::Application.new(skip_registration: true)
17
- app.versioning_scheme = [:header, :params]
18
- app.handler 'json' , Praxis::Handlers::JSON
19
- app.handler 'x-www-form-urlencoded', Praxis::Handlers::WWWForm
20
- app.api_definition.info do # applies to all API infos
21
- base_path "/api"
22
- end
23
- app
24
- end
25
-
15
+
26
16
  let(:action) { Instances.definition.actions[:show] }
27
17
 
28
18
  let(:context) do
@@ -34,7 +24,7 @@ describe Praxis::Request do
34
24
  end
35
25
 
36
26
  subject(:request) do
37
- request = Praxis::Request.new(env, application: application)
27
+ request = Praxis::Request.new(env)
38
28
  request.action = action
39
29
  request
40
30
  end
@@ -47,10 +37,10 @@ describe Praxis::Request do
47
37
  context 'path versioning' do
48
38
  before do
49
39
  allow(
50
- application
40
+ Praxis::Application.instance
51
41
  ).to receive(:versioning_scheme).and_return(:path)
52
42
  allow(
53
- application.api_definition.info
43
+ Praxis::ApiDefinition.instance.info
54
44
  ).to receive(:base_path).and_return('/api/v:api_version')
55
45
 
56
46
  end
@@ -74,7 +64,7 @@ describe Praxis::Request do
74
64
  let(:versioning_scheme){ Praxis::Request::VERSION_USING_DEFAULTS }
75
65
  before do
76
66
  allow(
77
- application
67
+ Praxis::Application.instance
78
68
  ).to receive(:versioning_scheme).and_return(versioning_scheme)
79
69
  end
80
70
 
@@ -94,7 +84,7 @@ describe Praxis::Request do
94
84
 
95
85
  before do
96
86
  allow(
97
- application.api_definition.info
87
+ Praxis::ApiDefinition.instance.info
98
88
  ).to receive(:base_path).and_return('/v:api_version')
99
89
  end
100
90
  it { should eq('5.0') }
@@ -219,7 +209,7 @@ describe Praxis::Request do
219
209
  let(:parsed_result){ double("parsed") }
220
210
 
221
211
  before do
222
- application.handler 'xml', Praxis::Handlers::XML
212
+ Praxis::Application.instance.handler 'xml', Praxis::Handlers::XML
223
213
  end
224
214
 
225
215
  after do
@@ -26,7 +26,14 @@ describe Praxis::RequestStages::Action do
26
26
 
27
27
  context '.execute' do
28
28
  before do
29
- expect(controller).to receive(action_stage.name).with(request.params_hash).and_return(controller_response)
29
+ expect(controller).to receive(action_stage.name) do |args|
30
+ if args
31
+ expect(args).to eq({})
32
+ else
33
+ expect(args).to eq(nil)
34
+ end
35
+ end.and_return(controller_response)
36
+
30
37
  end
31
38
  let(:controller_response){ controller.response }
32
39
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Praxis::RequestStages::Validate do
4
- let(:dispatcher) { Praxis::Dispatcher.new(application: APP) }
4
+ let(:dispatcher) { Praxis::Dispatcher.new }
5
5
 
6
6
  # Instances controller is defined in the 'app' folder and is already in scope. Using this
7
7
  # controller for the specs instead of creating a simple controller.
@@ -101,13 +101,12 @@ describe Praxis::ResourceDefinition do
101
101
 
102
102
  end
103
103
  end
104
- let(:praxis_application) do
105
- app = Praxis::Application.new(skip_registration: true)
106
- app.versioning_scheme = [:header, :params]
107
- app.handler 'json' , Praxis::Handlers::JSON
108
- app.handler 'x-www-form-urlencoded', Praxis::Handlers::WWWForm
109
- app.api_definition.instance_eval do |api_def|
110
- api_def.info do
104
+
105
+ let(:non_singleton_api) do
106
+ api_def=Praxis::ApiDefinition.__send__(:new)
107
+ api_def.instance_eval do |api|
108
+
109
+ api.info do
111
110
  base_path '/api/:base_param'
112
111
  base_params do
113
112
  attribute :base_param, String
@@ -117,23 +116,22 @@ describe Praxis::ResourceDefinition do
117
116
  end
118
117
  end
119
118
 
120
- api_def.info '1.0' do
119
+ api.info '1.0' do
121
120
  base_params do
122
121
  attribute :app_name, String
123
122
  end
124
123
  end
125
- api_def.info '2.0' do
124
+ api.info '2.0' do
126
125
  base_params do
127
126
  attribute :v2_param, String
128
127
  end
129
128
  end
130
-
131
129
  end
132
- app
130
+ api_def
133
131
  end
134
132
 
135
133
  before do
136
- allow(Praxis::Application).to receive(:instance).and_return(praxis_application)
134
+ allow(Praxis::ApiDefinition).to receive(:instance).and_return(non_singleton_api)
137
135
  end
138
136
 
139
137
  it 'are applied to actions' do
@@ -1,24 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Praxis::ResponseDefinition do
4
- let(:praxis_app) do
5
- app = Praxis::Application.new(skip_registration: true)
6
- app.versioning_scheme = [:header, :params]
7
- app.handler 'json' , Praxis::Handlers::JSON
8
- app.handler 'x-www-form-urlencoded', Praxis::Handlers::WWWForm
9
- app.handler 'xml', Praxis::Handlers::XML
10
- app.api_definition.instance_eval do |api_def|
11
- api_def.info do
12
- base_path "/api"
13
- produces 'json','xml'
14
- end
15
- end
16
- app
17
- end
18
-
19
-
20
-
21
- subject(:response_definition) { Praxis::ResponseDefinition.new(name, praxis_app, &block) }
4
+ subject(:response_definition) { Praxis::ResponseDefinition.new(name, &block) }
22
5
  let(:name) { 'response_name' }
23
6
 
24
7
  let(:block) do
@@ -465,7 +448,7 @@ describe Praxis::ResponseDefinition do
465
448
  context 'with legacy multipart response' do
466
449
  subject(:response) { Praxis::Responses::Ok.new(status: response_status, headers: response_headers) }
467
450
 
468
- let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, 'Content-Type' => 'application/special'},{}) }
451
+ let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, 'Content-Type' => 'application/special'},**{}) }
469
452
 
470
453
  before do
471
454
  response_definition.parts like: :ok, media_type: 'application/special'
@@ -480,7 +463,7 @@ describe Praxis::ResponseDefinition do
480
463
  end
481
464
 
482
465
  context 'with invalid part' do
483
- let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, "Location" => "somewhere"},{}) }
466
+ let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, "Location" => "somewhere"}) }
484
467
 
485
468
  it 'validates' do
486
469
  expect {
@@ -499,7 +482,7 @@ describe Praxis::ResponseDefinition do
499
482
  context 'with invalid definitions' do
500
483
  it 'raises an error if status code is not part of the definition' do
501
484
  expect do
502
- Praxis::ResponseDefinition.new('response name',praxis_app) do
485
+ Praxis::ResponseDefinition.new('response name') do
503
486
  description "testing"
504
487
  end
505
488
  end.to raise_error(Praxis::Exceptions::InvalidConfiguration)
@@ -511,9 +494,10 @@ describe Praxis::ResponseDefinition do
511
494
  let(:location) { %r{/my/url/} }
512
495
  let(:headers) { {'Header1' => 'Value1'} }
513
496
  let(:parts) { nil }
497
+ let(:parts_block) { nil }
514
498
 
515
499
  let(:response) do
516
- Praxis::ResponseDefinition.new(:custom, praxis_app) do
500
+ Praxis::ResponseDefinition.new(:custom) do
517
501
  status 300
518
502
  end
519
503
  end
@@ -522,7 +506,9 @@ describe Praxis::ResponseDefinition do
522
506
  before do
523
507
  response.description(description) if description
524
508
  response.location(location) if location
525
- response.parts(parts) if parts
509
+ if parts || parts_block
510
+ parts ? response.parts(nil, **parts, &parts_block) : response.parts(nil, &parts_block)
511
+ end
526
512
  response.headers(headers) if headers
527
513
  end
528
514
 
@@ -541,8 +527,8 @@ describe Praxis::ResponseDefinition do
541
527
  its(['xml', :content_type]) { should eq('application/vnd.acme.instance+xml') }
542
528
 
543
529
  it 'properly encodes the example bodies' do
544
- json = praxis_app.handlers['json'].parse(examples['json'][:body])
545
- xml = praxis_app.handlers['xml'].parse(examples['xml'][:body])
530
+ json = Praxis::Application.instance.handlers['json'].parse(examples['json'][:body])
531
+ xml = Praxis::Application.instance.handlers['xml'].parse(examples['xml'][:body])
546
532
  expect(json).to eq xml
547
533
  end
548
534
 
@@ -589,7 +575,7 @@ describe Praxis::ResponseDefinition do
589
575
  its([:status]){ should == 200 }
590
576
  end
591
577
  context 'using a full response definition block' do
592
- let(:parts) do
578
+ let(:parts_block) do
593
579
  Proc.new do
594
580
  status 234
595
581
  media_type 'custom_media'
@@ -49,14 +49,7 @@ describe Praxis::Response do
49
49
  end
50
50
 
51
51
  subject(:response) { Praxis::Responses::Ok.new(status: response_status, headers: response_headers) }
52
- let(:application) do
53
- double("PraxisApp", handlers: handlers, config: praxis_config)
54
- end
55
- let(:handlers) do
56
- {'json' => Praxis::Handlers::JSON.new }
57
- end
58
- let(:praxis_config){ double(praxis: double("...") ) }
59
-
52
+
60
53
  describe '#validate' do
61
54
  before do
62
55
  allow(action).to receive(:responses).and_return({response_spec.name => response_spec })
@@ -93,7 +86,7 @@ describe Praxis::Response do
93
86
  before { response.body = response_body_entity }
94
87
 
95
88
  it 'leaves well enough alone' do
96
- response.encode!(handlers: handlers)
89
+ response.encode!
97
90
  expect(response.body).to eq(response_body_entity)
98
91
  end
99
92
  end
@@ -102,7 +95,7 @@ describe Praxis::Response do
102
95
  before { response.body = response_body_structured_data }
103
96
 
104
97
  it 'encodes using a suitable handler' do
105
- response.encode!(handlers: handlers)
98
+ response.encode!
106
99
  expect(JSON.load(response.body)).to eq(response_body_structured_data)
107
100
  end
108
101
  end
@@ -115,7 +108,7 @@ describe Praxis::Response do
115
108
  'Location' => '/api/resources/123' }
116
109
  }
117
110
  it 'still defaults to the default handler' do
118
- response.encode!(handlers: handlers)
111
+ response.encode!
119
112
  expect(JSON.load(response.body)).to eq(response_body_structured_data)
120
113
  end
121
114
  end
@@ -124,7 +117,7 @@ describe Praxis::Response do
124
117
  end
125
118
 
126
119
  context 'multipart responses' do
127
- let(:part) { Praxis::MultipartPart.new('not so ok', {'Status' => 400, "Location" => "somewhere"}, {}) }
120
+ let(:part) { Praxis::MultipartPart.new('not so ok', {'Status' => 400, "Location" => "somewhere"}) }
128
121
 
129
122
  context '#add_part' do
130
123
 
@@ -165,7 +158,7 @@ describe Praxis::Response do
165
158
  response.status = 500
166
159
  end
167
160
 
168
- let!(:finished_response) { response.finish(application: application) }
161
+ let!(:finished_response) { response.finish }
169
162
 
170
163
  it 'returns status, headers, body' do
171
164
  expect(finished_response).to eq([response.status, response.headers, response.body])
@@ -17,12 +17,15 @@ describe Praxis::Responses::InternalServerError do
17
17
 
18
18
 
19
19
  context '.format!' do
20
- let(:app){ double("PraxisApp", config: double(praxis: config)) }
21
20
  let(:error) { double('error', message: 'error message', backtrace: [1, 2], cause: cause) }
22
21
 
23
22
  let(:show_exceptions) { true }
24
23
  let(:config) { double("config", show_exceptions: show_exceptions) }
25
24
 
25
+ before do
26
+ allow(Praxis::Application.instance.config).to receive(:praxis).and_return(config)
27
+ end
28
+
26
29
  context 'with show_exceptions false' do
27
30
  end
28
31
 
@@ -50,7 +53,7 @@ describe Praxis::Responses::InternalServerError do
50
53
  subject(:response) { Praxis::Responses::InternalServerError.new(error: error) }
51
54
  before do
52
55
  expect(response.body).to be_nil
53
- response.format!(config: app.config)
56
+ response.format!
54
57
  end
55
58
 
56
59
  end
@@ -1,17 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Praxis::Router do
4
- let(:application) do
5
- app = Praxis::Application.new(skip_registration: true)
6
- app.versioning_scheme = [:header, :params]
7
- app
8
- end
9
4
  describe Praxis::Router::VersionMatcher do
10
5
  let(:resource_definition){ double("resource_definition", version_options: { using: [:header, :params] }) }
11
6
  let(:action){ double("action", resource_definition: resource_definition ) }
12
7
  let(:target){ double("target", action: action ) }
13
8
  let(:args){ {version: "1.0"} }
14
- subject(:matcher){ Praxis::Router::VersionMatcher.new(target,args) }
9
+ subject(:matcher){ Praxis::Router::VersionMatcher.new(target,**args) }
15
10
 
16
11
  context '.initialize' do
17
12
  let(:args){ {} }
@@ -22,7 +17,7 @@ describe Praxis::Router do
22
17
 
23
18
  context '.call' do
24
19
  let(:env){ {"HTTP_X_API_VERSION" => request_version } }
25
- let(:request) {Praxis::Request.new(env,application: application)}
20
+ let(:request) {Praxis::Request.new(env)}
26
21
 
27
22
  context 'with matching versions' do
28
23
  let(:request_version) { "1.0" }
@@ -72,6 +67,7 @@ describe Praxis::Router do
72
67
  end
73
68
  end
74
69
 
70
+ let(:application) { instance_double('Praxis::Application')}
75
71
  subject(:router) {Praxis::Router.new(application)}
76
72
 
77
73
  context "attributes" do
@@ -108,7 +104,7 @@ describe Praxis::Router do
108
104
  let(:request_verb) { 'POST' }
109
105
  let(:request_path_info) { '/' }
110
106
  let(:request_version){ nil }
111
- let(:request) {Praxis::Request.new(env, application: application)}
107
+ let(:request) {Praxis::Request.new(env)}
112
108
  let(:router_response){ 1 }
113
109
  let(:router_response_for_post){ "POST result" }
114
110
  let(:router_response_for_wildcard){ "* result" }
@@ -189,7 +185,7 @@ describe Praxis::Router do
189
185
  end
190
186
 
191
187
  context 'with X-Cascade disabled' do
192
- let(:config) { application.config.praxis }
188
+ let(:config) { Praxis::Application.instance.config.praxis }
193
189
  before do
194
190
  expect(config).to receive(:x_cascade).and_return(false)
195
191
  end
@@ -73,7 +73,7 @@ class Instances < BaseClass
73
73
 
74
74
  headers = {
75
75
  'Status' => '201',
76
- 'Content-Type' => Instance.identifier + '+json',
76
+ 'Content-Type' => (Instance.identifier + '+json').to_s,
77
77
  'Location' => definition.to_href(cloud_id: cloud_id, id: instance.id)
78
78
  }
79
79
 
@@ -9,4 +9,9 @@ $:.unshift File.expand_path('lib', __dir__)
9
9
 
10
10
  require 'praxis'
11
11
 
12
- run Praxis::Application.new.setup
12
+
13
+ application = Praxis::Application.instance
14
+
15
+ application.setup
16
+
17
+ run application