praxis 0.21 → 0.22.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +20 -12
  3. data/CHANGELOG.md +24 -0
  4. data/CONTRIBUTING.md +4 -4
  5. data/README.md +11 -9
  6. data/lib/api_browser/app/js/directives/attribute_table.js +2 -1
  7. data/lib/api_browser/app/js/directives/conditional_requirements.js +13 -0
  8. data/lib/api_browser/app/js/directives/type_placeholder.js +10 -1
  9. data/lib/api_browser/app/js/factories/normalize_attributes.js +4 -2
  10. data/lib/api_browser/app/js/factories/template_for.js +5 -2
  11. data/lib/api_browser/app/js/filters/has_requirement.js +14 -0
  12. data/lib/api_browser/app/js/filters/tag_requirement.js +13 -0
  13. data/lib/api_browser/app/sass/praxis.scss +11 -0
  14. data/lib/api_browser/app/views/action.html +2 -2
  15. data/lib/api_browser/app/views/directives/attribute_description/member_options.html +2 -2
  16. data/lib/api_browser/app/views/directives/attribute_table.html +1 -1
  17. data/lib/api_browser/app/views/type.html +1 -1
  18. data/lib/api_browser/app/views/type/details.html +2 -2
  19. data/lib/api_browser/app/views/types/embedded/array.html +2 -0
  20. data/lib/api_browser/app/views/types/embedded/default.html +3 -1
  21. data/lib/api_browser/app/views/types/embedded/requirements.html +6 -0
  22. data/lib/api_browser/app/views/types/embedded/single_req.html +9 -0
  23. data/lib/api_browser/app/views/types/embedded/struct.html +14 -2
  24. data/lib/api_browser/app/views/types/standalone/array.html +1 -1
  25. data/lib/api_browser/app/views/types/standalone/struct.html +2 -1
  26. data/lib/api_browser/package.json +1 -1
  27. data/lib/praxis.rb +8 -6
  28. data/lib/praxis/action_definition.rb +9 -7
  29. data/lib/praxis/api_definition.rb +44 -27
  30. data/lib/praxis/api_general_info.rb +3 -2
  31. data/lib/praxis/application.rb +139 -20
  32. data/lib/praxis/bootloader.rb +2 -4
  33. data/lib/praxis/bootloader_stages/environment.rb +0 -13
  34. data/lib/praxis/controller.rb +2 -0
  35. data/lib/praxis/dispatcher.rb +16 -10
  36. data/lib/praxis/docs/generator.rb +20 -9
  37. data/lib/praxis/docs/link_builder.rb +1 -1
  38. data/lib/praxis/error_handler.rb +5 -5
  39. data/lib/praxis/extensions/attribute_filtering.rb +28 -0
  40. data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +180 -0
  41. data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +273 -0
  42. data/lib/praxis/extensions/attribute_filtering/query_builder.rb +39 -0
  43. data/lib/praxis/extensions/field_selection.rb +3 -0
  44. data/lib/praxis/extensions/field_selection/active_record_query_selector.rb +57 -0
  45. data/lib/praxis/extensions/field_selection/sequel_query_selector.rb +65 -0
  46. data/lib/praxis/extensions/rails_compat.rb +2 -0
  47. data/lib/praxis/extensions/rails_compat/request_methods.rb +19 -0
  48. data/lib/praxis/extensions/rendering.rb +1 -1
  49. data/lib/praxis/file_group.rb +1 -1
  50. data/lib/praxis/middleware_app.rb +26 -6
  51. data/lib/praxis/multipart/parser.rb +14 -2
  52. data/lib/praxis/multipart/part.rb +5 -3
  53. data/lib/praxis/plugins/praxis_mapper_plugin.rb +2 -2
  54. data/lib/praxis/plugins/rails_plugin.rb +104 -0
  55. data/lib/praxis/request.rb +8 -9
  56. data/lib/praxis/request_stages/response.rb +3 -2
  57. data/lib/praxis/request_superclassing.rb +11 -0
  58. data/lib/praxis/resource_definition.rb +14 -10
  59. data/lib/praxis/response.rb +6 -7
  60. data/lib/praxis/response_definition.rb +7 -5
  61. data/lib/praxis/response_template.rb +4 -3
  62. data/lib/praxis/responses/http.rb +0 -36
  63. data/lib/praxis/responses/internal_server_error.rb +3 -12
  64. data/lib/praxis/responses/multipart_ok.rb +4 -11
  65. data/lib/praxis/responses/validation_error.rb +1 -10
  66. data/lib/praxis/router.rb +3 -3
  67. data/lib/praxis/tasks/api_docs.rb +10 -2
  68. data/lib/praxis/tasks/routes.rb +1 -0
  69. data/lib/praxis/version.rb +1 -1
  70. data/praxis.gemspec +4 -5
  71. data/spec/functional_spec.rb +4 -6
  72. data/spec/praxis/action_definition_spec.rb +26 -15
  73. data/spec/praxis/api_definition_spec.rb +13 -8
  74. data/spec/praxis/api_general_info_spec.rb +3 -8
  75. data/spec/praxis/application_spec.rb +13 -7
  76. data/spec/praxis/middleware_app_spec.rb +24 -10
  77. data/spec/praxis/request_spec.rb +17 -7
  78. data/spec/praxis/request_stages/validate_spec.rb +1 -1
  79. data/spec/praxis/resource_definition_spec.rb +12 -10
  80. data/spec/praxis/response_definition_spec.rb +22 -5
  81. data/spec/praxis/response_spec.rb +12 -5
  82. data/spec/praxis/responses/internal_server_error_spec.rb +4 -7
  83. data/spec/praxis/responses/validation_error_spec.rb +2 -2
  84. data/spec/praxis/router_spec.rb +8 -4
  85. data/spec/spec_app/config.ru +1 -6
  86. data/spec/spec_helper.rb +3 -3
  87. data/tasks/thor/templates/generator/empty_app/Gemfile +3 -3
  88. metadata +36 -32
  89. data/.ruby-version +0 -1
  90. data/lib/praxis/stats.rb +0 -113
  91. data/spec/praxis/stats_spec.rb +0 -9
data/praxis.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.email = ["blanquer@gmail.com","dane.jensen@gmail.com"]
13
13
 
14
- spec.homepage = "https://github.com/rightscale/praxis"
14
+ spec.homepage = "https://github.com/praxis/praxis"
15
15
  spec.license = "MIT"
16
16
  spec.required_ruby_version = ">=2.1"
17
17
 
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.bindir = 'bin'
21
21
  spec.executables << 'praxis'
22
22
 
23
- spec.add_dependency 'rack', '~> 1'
24
- spec.add_dependency 'mustermann', '~> 0'
23
+ spec.add_dependency 'rack', '>= 1'
24
+ spec.add_dependency 'mustermann', '>=0', '<=1'
25
25
  spec.add_dependency 'activesupport', '>= 3'
26
26
  spec.add_dependency 'mime', '~> 0'
27
27
  spec.add_dependency 'praxis-mapper', '~> 4.3'
@@ -29,9 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'attributor', '~> 5.1'
30
30
  spec.add_dependency 'thor', '~> 0.18'
31
31
  spec.add_dependency 'terminal-table', '~> 1.4'
32
- spec.add_dependency 'harness', '~> 2'
33
32
 
34
- spec.add_development_dependency 'bundler', '~> 1.6'
33
+ spec.add_development_dependency 'bundler'
35
34
  spec.add_development_dependency 'rake', '~> 0.9'
36
35
  spec.add_development_dependency 'rake-notes', '~> 0'
37
36
  if RUBY_PLATFORM !~ /java/
@@ -333,11 +333,11 @@ describe 'Functional specs' do
333
333
 
334
334
  context 'wildcard verb routing' do
335
335
  it 'can terminate instances with POST' do
336
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'global_session' => session
336
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
337
337
  expect(last_response.status).to eq(200)
338
338
  end
339
339
  it 'can terminate instances with DELETE' do
340
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'global_session' => session
340
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
341
341
  expect(last_response.status).to eq(200)
342
342
  end
343
343
 
@@ -352,18 +352,16 @@ describe 'Functional specs' do
352
352
  get '/api/clouds/23/otherinstances/_action/exceptional?api_version=1.0', nil, 'global_session' => session
353
353
  expect(last_response.status).to eq(404)
354
354
  end
355
-
356
-
357
355
  end
358
356
 
359
357
  context 'auth_plugin' do
360
358
  it 'can terminate' do
361
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'global_session' => session
359
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
362
360
  expect(last_response.status).to eq(200)
363
361
  end
364
362
 
365
363
  it 'can not stop' do
366
- post '/api/clouds/23/instances/1/stop?api_version=1.0', nil, 'global_session' => session
364
+ post '/api/clouds/23/instances/1/stop?api_version=1.0', '', 'global_session' => session
367
365
  expect(last_response.status).to eq(403)
368
366
  end
369
367
  end
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Praxis::ActionDefinition do
4
+
5
+ before(:context) do
6
+ Thread.current[:praxis_instance] = Praxis::Application.new(name: 'action_definition_spec', skip_registration: true)
7
+ end
8
+
9
+ let(:praxis_instance) do
10
+ Thread.current[:praxis_instance]
11
+ end
12
+
4
13
  class SpecMediaType < Praxis::MediaType
5
14
  identifier 'application/json'
6
15
 
@@ -31,10 +40,8 @@ describe Praxis::ActionDefinition do
31
40
  end
32
41
  end
33
42
  end
34
-
35
43
  subject(:action) do
36
-
37
- Praxis::ApiDefinition.define do |api|
44
+ praxis_instance.api_definition.define do |api|
38
45
  api.response_template :ok do |media_type: , location: nil, headers: nil, description: nil |
39
46
  status 200
40
47
 
@@ -42,6 +49,10 @@ describe Praxis::ActionDefinition do
42
49
  location location
43
50
  headers headers if headers
44
51
  end
52
+
53
+ api.info do # applies to all API infos
54
+ base_path "/pref"
55
+ end
45
56
  end
46
57
  Praxis::ActionDefinition.new(:foo, resource_definition) do
47
58
  routing { get '/:one' }
@@ -111,11 +122,11 @@ describe Praxis::ActionDefinition do
111
122
  let(:traits) { {test: trait} }
112
123
 
113
124
  before do
114
- allow(Praxis::ApiDefinition.instance).to receive(:traits).and_return(traits)
125
+ allow(praxis_instance.api_definition).to receive(:traits).and_return(traits)
115
126
  end
116
127
 
117
128
  its('params.attributes.keys') { should eq [:inherited, :app_name, :name, :one]}
118
- its('routes.first.path.to_s') { should eq '/api/foobars/hello_world/test_trait/:app_name/:one' }
129
+ its('routes.first.path.to_s') { should eq '/pref/foobars/hello_world/test_trait/:app_name/:one' }
119
130
  its(:traits) { should eq [:test] }
120
131
 
121
132
  it 'is reflected in the describe output' do
@@ -315,11 +326,9 @@ describe Praxis::ActionDefinition do
315
326
  end
316
327
 
317
328
  context 'with a base_path and base_params on ApiDefinition' do
318
- # Without getting a fresh new ApiDefinition it is very difficult to test stuff using the Singleton
319
- # So for some tests we're gonna create a new instance and work with it to avoid the singleton issues
320
- let(:non_singleton_api) do
321
- api_def=Praxis::ApiDefinition.__send__(:new)
322
- api_def.instance_eval do |api|
329
+ subject(:action) do
330
+ api_def=Praxis::ApiDefinition.new(praxis_instance)
331
+ api_def.define do |api|
323
332
 
324
333
  api.info do
325
334
  base_path '/apps/:app_name'
@@ -332,11 +341,13 @@ describe Praxis::ActionDefinition do
332
341
  end
333
342
 
334
343
  end
335
- api_def
336
- end
337
-
338
- before do
339
- allow(Praxis::ApiDefinition).to receive(:instance).and_return(non_singleton_api)
344
+ # No setter...and its fine to do it here as it would not be used in a runtime situation
345
+ praxis_instance.instance_variable_set(:@api_definition, api_def)
346
+ # Define the action after the api_definition is set (as it uses is config to setup the routes)
347
+ Praxis::ActionDefinition.new(:bar, resource_definition) do
348
+ routing { get '/:one' }
349
+ params { attribute :one, String }
350
+ end
340
351
  end
341
352
 
342
353
  its('routes.first.path.to_s') { should eq '/apps/:app_name/foobars/hello_world/:one' }
@@ -2,12 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe Praxis::ApiDefinition do
4
4
 
5
- subject(:api){ Praxis::ApiDefinition.instance }
5
+ # TODO: perhaps grab the spec app instance from some global var...(instead of relying on the singleton compat method)
6
+ subject(:api){ Praxis::ApiDefinition.instance }
6
7
 
7
8
  # Without getting a fresh new ApiDefinition it is very difficult to test stuff using the Singleton
8
9
  # So for some tests we're gonna create a new instance and work with it to avoid the singleton issues
10
+ let(:app_instance){ double("AppInstance") }
11
+ before do
12
+ allow(app_instance).to receive(:versioning_scheme=).with([:header, :params])
13
+ end
14
+
9
15
  let(:non_singleton_api) do
10
- api_def=Praxis::ApiDefinition.__send__(:new)
16
+ api_def=Praxis::ApiDefinition.new(app_instance)
11
17
  api_def.instance_eval do |api|
12
18
  api.response_template :template1, &Proc.new {}
13
19
  api.trait :trait1, &Proc.new {}
@@ -32,12 +38,7 @@ describe Praxis::ApiDefinition do
32
38
  end
33
39
  end
34
40
 
35
- context 'singleton' do
36
- it 'should be a Singleton' do
37
- expect(Praxis::ApiDefinition.ancestors).to include( Singleton )
38
- expect(subject).to eq(Praxis::ApiDefinition.instance )
39
- end
40
-
41
+ context 'initial definition' do
41
42
  it 'has the :ok and :created response templates registered' do
42
43
  expect(api.responses.keys).to include(:ok)
43
44
  expect(api.responses.keys).to include(:created)
@@ -58,6 +59,10 @@ describe Praxis::ApiDefinition do
58
59
  expect(api.responses.keys).to include(:foobar)
59
60
  expect(api.response(:foobar)).to be_kind_of(Praxis::ResponseTemplate)
60
61
  end
62
+ it 'stores the app instance' do
63
+ template = api.response(:template1)
64
+ expect(template.application).to be(app_instance)
65
+ end
61
66
  end
62
67
 
63
68
  context '.response' do
@@ -2,12 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Praxis::ApiGeneralInfo do
4
4
 
5
- subject(:info){ Praxis::ApiGeneralInfo.new }
6
-
7
- before do
8
- allow(Praxis::Application.instance).to receive(:versioning_scheme=).with([:header, :params])
9
- end
10
-
5
+ subject(:info){ Praxis::ApiGeneralInfo.new(application: APP) }
11
6
 
12
7
  let(:info_block) do
13
8
  Proc.new do
@@ -64,8 +59,8 @@ describe Praxis::ApiGeneralInfo do
64
59
  end
65
60
 
66
61
  context 'base_path with versioning' do
67
- let(:global_info){ Praxis::ApiGeneralInfo.new }
68
- subject(:info){ Praxis::ApiGeneralInfo.new(global_info, version: '1.0') }
62
+ let(:global_info){ Praxis::ApiGeneralInfo.new(application: APP) }
63
+ subject(:info){ Praxis::ApiGeneralInfo.new(global_info, application: APP, version: '1.0') }
69
64
 
70
65
  before do
71
66
  global_info
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Praxis::Application do
4
4
  context 'configuration' do
5
5
  subject(:app) do
6
- app = Class.new(Praxis::Application).instance
6
+ app = Class.new(Praxis::Application).new(skip_registration: true)
7
7
 
8
8
  config = Object.new
9
9
  def config.define(key=nil, type=Attributor::Struct, **opts, &block)
@@ -45,7 +45,7 @@ describe Praxis::Application do
45
45
  end
46
46
 
47
47
  context 'media type handlers' do
48
- subject { Class.new(Praxis::Application).instance }
48
+ subject { Class.new(Praxis::Application).new(skip_registration: true) }
49
49
 
50
50
  before do
51
51
  # don't actually bootload; we're merely running specs
@@ -94,12 +94,14 @@ describe Praxis::Application do
94
94
  end
95
95
 
96
96
  describe '#setup' do
97
- subject { Class.new(Praxis::Application).instance }
98
-
97
+ subject { Praxis::Application.new(skip_registration: true) }
98
+ let(:boot_loader) { double("BL", setup!: true) }
99
+ let(:builder) { double("Builder", to_app: double('Rack app'), run: true) }
100
+
99
101
  before do
100
- # don't actually bootload; we're merely running specs
101
- allow(subject.bootloader).to receive(:setup!).and_return(true)
102
- allow(subject.builder).to receive(:to_app).and_return(double('Rack app'))
102
+ # don't actually bootload; we're merely running specs
103
+ allow(subject).to receive(:bootloader).and_return(boot_loader)
104
+ allow(subject).to receive(:builder).and_return(builder)
103
105
  end
104
106
 
105
107
  it 'is idempotent' do
@@ -112,5 +114,9 @@ describe Praxis::Application do
112
114
  expect(subject.setup).to eq(subject)
113
115
  expect(subject.setup).to eq(subject)
114
116
  end
117
+
118
+ it 'creates an ApiDefinition that has a back-reference' do
119
+ expect(subject.api_definition.application).to eq(subject)
120
+ end
115
121
  end
116
122
  end
@@ -2,35 +2,49 @@ require 'spec_helper'
2
2
 
3
3
  describe Praxis::MiddlewareApp do
4
4
 
5
- context '.for' do
6
- let(:init_args){ { root: 'here'} }
7
- subject(:middleware) { Praxis::MiddlewareApp.for( init_args ) }
5
+ let(:init_args){ { root: 'here', name: 'middleware_app_spec', skip_registration: true} }
6
+ let(:middleware) { Praxis::MiddlewareApp.for( init_args ) }
7
+ let(:instance){ middleware.new(target)}
8
8
 
9
- it 'initializes the application singletone with the passed parameters' do
10
- expect( Praxis::Application.instance ).to receive(:setup).with( init_args ).once
11
- subject
9
+ context '.for' do
10
+ it 'does not initialize the Application instance yet' do
11
+ expect( Praxis::Application.instance ).to_not receive(:setup)
12
+ middleware
12
13
  end
13
14
  it 'returns its class' do
14
- expect( subject ).to be( Praxis::MiddlewareApp )
15
+ expect( middleware ).to be < Praxis::MiddlewareApp
15
16
  end
16
17
  end
17
18
 
18
19
  context 'instantiated' do
20
+ subject{ instance }
19
21
  let(:target_response){ [201,{}] }
20
22
  let(:target){ double("target app", call: target_response) }
21
- subject(:instance){ Praxis::MiddlewareApp.new(target)}
22
23
  it 'saves the target app' do
23
24
  expect(subject.target).to be(target)
24
25
  end
26
+ it 'does not initialize the Application instance yet' do
27
+ expect( Praxis::Application.instance ).to_not receive(:setup)
28
+ subject
29
+ end
30
+
25
31
  context '.call' do
32
+ let(:the_instance) { double("The instance", setup: nil) }
26
33
  let(:env){ {} }
27
34
  let(:praxis_response){ [200,{}] }
28
- subject(:response){ Praxis::MiddlewareApp.new(target).call(env) }
35
+ subject(:response){ instance.call(env) }
29
36
  before do
30
37
  # always invokes the praxis app
31
- expect( Praxis::Application.instance ).to receive(:call).with( env ).once.and_return(praxis_response)
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)
32
41
  end
33
42
 
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
46
+ end
47
+
34
48
  context 'properly handled (non-404 and 405) responses from praxis' do
35
49
  it 'are returned straight through' do
36
50
  expect( response ).to be(praxis_response)
@@ -12,7 +12,17 @@ describe Praxis::Request do
12
12
  env['HTTP_AUTHORIZATION'] = 'Secret'
13
13
  env
14
14
  end
15
-
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
+
16
26
  let(:action) { Instances.definition.actions[:show] }
17
27
 
18
28
  let(:context) do
@@ -24,7 +34,7 @@ describe Praxis::Request do
24
34
  end
25
35
 
26
36
  subject(:request) do
27
- request = Praxis::Request.new(env)
37
+ request = Praxis::Request.new(env, application: application)
28
38
  request.action = action
29
39
  request
30
40
  end
@@ -37,10 +47,10 @@ describe Praxis::Request do
37
47
  context 'path versioning' do
38
48
  before do
39
49
  allow(
40
- Praxis::Application.instance
50
+ application
41
51
  ).to receive(:versioning_scheme).and_return(:path)
42
52
  allow(
43
- Praxis::ApiDefinition.instance.info
53
+ application.api_definition.info
44
54
  ).to receive(:base_path).and_return('/api/v:api_version')
45
55
 
46
56
  end
@@ -64,7 +74,7 @@ describe Praxis::Request do
64
74
  let(:versioning_scheme){ Praxis::Request::VERSION_USING_DEFAULTS }
65
75
  before do
66
76
  allow(
67
- Praxis::Application.instance
77
+ application
68
78
  ).to receive(:versioning_scheme).and_return(versioning_scheme)
69
79
  end
70
80
 
@@ -84,7 +94,7 @@ describe Praxis::Request do
84
94
 
85
95
  before do
86
96
  allow(
87
- Praxis::ApiDefinition.instance.info
97
+ application.api_definition.info
88
98
  ).to receive(:base_path).and_return('/v:api_version')
89
99
  end
90
100
  it { should eq('5.0') }
@@ -209,7 +219,7 @@ describe Praxis::Request do
209
219
  let(:parsed_result){ double("parsed") }
210
220
 
211
221
  before do
212
- Praxis::Application.instance.handler 'xml', Praxis::Handlers::XML
222
+ application.handler 'xml', Praxis::Handlers::XML
213
223
  end
214
224
 
215
225
  after do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Praxis::RequestStages::Validate do
4
- let(:dispatcher) { Praxis::Dispatcher.new }
4
+ let(:dispatcher) { Praxis::Dispatcher.new(application: APP) }
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,12 +101,13 @@ describe Praxis::ResourceDefinition do
101
101
 
102
102
  end
103
103
  end
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
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
110
111
  base_path '/api/:base_param'
111
112
  base_params do
112
113
  attribute :base_param, String
@@ -116,22 +117,23 @@ describe Praxis::ResourceDefinition do
116
117
  end
117
118
  end
118
119
 
119
- api.info '1.0' do
120
+ api_def.info '1.0' do
120
121
  base_params do
121
122
  attribute :app_name, String
122
123
  end
123
124
  end
124
- api.info '2.0' do
125
+ api_def.info '2.0' do
125
126
  base_params do
126
127
  attribute :v2_param, String
127
128
  end
128
129
  end
130
+
129
131
  end
130
- api_def
132
+ app
131
133
  end
132
134
 
133
135
  before do
134
- allow(Praxis::ApiDefinition).to receive(:instance).and_return(non_singleton_api)
136
+ allow(Praxis::Application).to receive(:instance).and_return(praxis_application)
135
137
  end
136
138
 
137
139
  it 'are applied to actions' do