praxis 2.0.pre.1 → 2.0.pre.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +5 -20
  5. data/CHANGELOG.md +32 -0
  6. data/Gemfile +1 -1
  7. data/Guardfile +2 -1
  8. data/Rakefile +1 -7
  9. data/TODO.md +28 -0
  10. data/lib/api_browser/package-lock.json +7110 -0
  11. data/lib/praxis.rb +7 -4
  12. data/lib/praxis/action_definition.rb +10 -17
  13. data/lib/praxis/action_definition/headers_dsl_compiler.rb +1 -1
  14. data/lib/praxis/api_general_info.rb +21 -0
  15. data/lib/praxis/application.rb +2 -3
  16. data/lib/praxis/bootloader_stages/routing.rb +2 -4
  17. data/lib/praxis/config.rb +1 -1
  18. data/lib/praxis/docs/generator.rb +11 -6
  19. data/lib/praxis/docs/open_api_generator.rb +255 -0
  20. data/lib/praxis/docs/openapi/info_object.rb +31 -0
  21. data/lib/praxis/docs/openapi/media_type_object.rb +59 -0
  22. data/lib/praxis/docs/openapi/operation_object.rb +40 -0
  23. data/lib/praxis/docs/openapi/parameter_object.rb +69 -0
  24. data/lib/praxis/docs/openapi/paths_object.rb +58 -0
  25. data/lib/praxis/docs/openapi/request_body_object.rb +51 -0
  26. data/lib/praxis/docs/openapi/response_object.rb +63 -0
  27. data/lib/praxis/docs/openapi/responses_object.rb +44 -0
  28. data/lib/praxis/docs/openapi/schema_object.rb +87 -0
  29. data/lib/praxis/docs/openapi/server_object.rb +24 -0
  30. data/lib/praxis/docs/openapi/tag_object.rb +21 -0
  31. data/lib/praxis/extensions/attribute_filtering.rb +2 -0
  32. data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +148 -157
  33. data/lib/praxis/extensions/attribute_filtering/active_record_patches.rb +15 -0
  34. data/lib/praxis/extensions/attribute_filtering/active_record_patches/5x.rb +90 -0
  35. data/lib/praxis/extensions/attribute_filtering/active_record_patches/6_0.rb +68 -0
  36. data/lib/praxis/extensions/attribute_filtering/active_record_patches/6_1_plus.rb +58 -0
  37. data/lib/praxis/extensions/attribute_filtering/filter_tree_node.rb +35 -0
  38. data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +13 -12
  39. data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +3 -2
  40. data/lib/praxis/extensions/field_selection/active_record_query_selector.rb +24 -30
  41. data/lib/praxis/extensions/field_selection/field_selector.rb +4 -0
  42. data/lib/praxis/extensions/field_selection/sequel_query_selector.rb +32 -39
  43. data/lib/praxis/extensions/pagination.rb +130 -0
  44. data/lib/praxis/extensions/pagination/active_record_pagination_handler.rb +42 -0
  45. data/lib/praxis/extensions/pagination/header_generator.rb +70 -0
  46. data/lib/praxis/extensions/pagination/ordering_params.rb +234 -0
  47. data/lib/praxis/extensions/pagination/pagination_handler.rb +68 -0
  48. data/lib/praxis/extensions/pagination/pagination_params.rb +374 -0
  49. data/lib/praxis/extensions/pagination/sequel_pagination_handler.rb +45 -0
  50. data/lib/praxis/handlers/json.rb +2 -0
  51. data/lib/praxis/handlers/www_form.rb +5 -0
  52. data/lib/praxis/handlers/{xml.rb → xml-sample.rb} +6 -0
  53. data/lib/praxis/links.rb +4 -0
  54. data/lib/praxis/mapper/active_model_compat.rb +57 -4
  55. data/lib/praxis/mapper/resource.rb +18 -11
  56. data/lib/praxis/mapper/selector_generator.rb +99 -75
  57. data/lib/praxis/mapper/sequel_compat.rb +43 -3
  58. data/lib/praxis/media_type.rb +1 -56
  59. data/lib/praxis/media_type_identifier.rb +2 -1
  60. data/lib/praxis/multipart/part.rb +5 -2
  61. data/lib/praxis/notifications.rb +1 -1
  62. data/lib/praxis/plugins/mapper_plugin.rb +17 -3
  63. data/lib/praxis/plugins/pagination_plugin.rb +71 -0
  64. data/lib/praxis/resource_definition.rb +8 -16
  65. data/lib/praxis/response_definition.rb +1 -1
  66. data/lib/praxis/route.rb +3 -5
  67. data/lib/praxis/routing_config.rb +3 -7
  68. data/lib/praxis/tasks/api_docs.rb +23 -0
  69. data/lib/praxis/tasks/routes.rb +9 -14
  70. data/lib/praxis/trait.rb +1 -1
  71. data/lib/praxis/types/media_type_common.rb +12 -2
  72. data/lib/praxis/types/multipart.rb +1 -1
  73. data/lib/praxis/types/multipart_array.rb +64 -2
  74. data/lib/praxis/types/multipart_array/part_definition.rb +1 -1
  75. data/lib/praxis/validation_handler.rb +1 -2
  76. data/lib/praxis/version.rb +1 -1
  77. data/praxis.gemspec +11 -9
  78. data/spec/functional_spec.rb +9 -6
  79. data/spec/praxis/action_definition_spec.rb +4 -16
  80. data/spec/praxis/api_general_info_spec.rb +6 -6
  81. data/spec/praxis/application_spec.rb +1 -1
  82. data/spec/praxis/collection_spec.rb +3 -2
  83. data/spec/praxis/config_spec.rb +2 -2
  84. data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +304 -0
  85. data/spec/praxis/extensions/attribute_filtering/filter_tree_node_spec.rb +39 -0
  86. data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +34 -0
  87. data/spec/praxis/extensions/field_expansion_spec.rb +6 -24
  88. data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +110 -0
  89. data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +148 -0
  90. data/spec/praxis/extensions/pagination/active_record_pagination_handler_spec.rb +130 -0
  91. data/spec/praxis/extensions/support/spec_resources_active_model.rb +173 -0
  92. data/spec/praxis/extensions/support/spec_resources_sequel.rb +106 -0
  93. data/spec/praxis/mapper/selector_generator_spec.rb +306 -282
  94. data/spec/praxis/media_type_spec.rb +5 -139
  95. data/spec/praxis/middleware_app_spec.rb +1 -1
  96. data/spec/praxis/request_spec.rb +3 -22
  97. data/spec/praxis/request_stages/action_spec.rb +8 -1
  98. data/spec/praxis/resource_definition_spec.rb +1 -1
  99. data/spec/praxis/response_definition_spec.rb +15 -13
  100. data/spec/praxis/response_spec.rb +1 -1
  101. data/spec/praxis/route_spec.rb +2 -9
  102. data/spec/praxis/router_spec.rb +1 -1
  103. data/spec/praxis/routing_config_spec.rb +4 -13
  104. data/spec/praxis/types/multipart_array_spec.rb +4 -21
  105. data/spec/spec_app/app/controllers/instances.rb +1 -1
  106. data/spec/spec_app/config/environment.rb +0 -2
  107. data/spec/spec_app/design/api.rb +7 -1
  108. data/spec/spec_app/design/media_types/instance.rb +0 -8
  109. data/spec/spec_app/design/media_types/volume.rb +0 -12
  110. data/spec/spec_app/design/resources/instances.rb +1 -2
  111. data/spec/spec_helper.rb +17 -0
  112. data/spec/support/be_deep_equal_matcher.rb +39 -0
  113. data/spec/support/spec_media_types.rb +0 -73
  114. data/spec/support/spec_resources.rb +42 -49
  115. metadata +91 -56
  116. data/spec/praxis/handlers/xml_spec.rb +0 -177
  117. data/spec/praxis/links_spec.rb +0 -68
  118. data/spec/spec_app/app/models/person.rb +0 -3
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Praxis::MediaType do
4
- let(:owner_resource) { instance_double(Person, id: 100, name: /[:name:]/.gen, href: '/', links: ['one','two']) }
5
- let(:manager_resource) { instance_double(Person, id: 101, name: /[:name:]/.gen, href: '/', links: []) }
6
- let(:custodian_resource) { instance_double(Person, id: 102, name: /[:name:]/.gen, href: '/', links: []) }
4
+ let(:owner_resource) { instance_double(Person, id: 100, name: /[:name:]/.gen, href: '/') }
5
+ let(:manager_resource) { instance_double(Person, id: 101, name: /[:name:]/.gen, href: '/') }
6
+ let(:custodian_resource) { instance_double(Person, id: 102, name: /[:name:]/.gen, href: '/') }
7
7
  let(:residents_summary_resource) do
8
8
  instance_double(Person::CollectionSummary, href: "/people", size: 2)
9
9
  end
@@ -27,15 +27,6 @@ describe Praxis::MediaType do
27
27
  its(:id) { should eq(1) }
28
28
  its(:name) { should eq('Home') }
29
29
  its(:owner) { should be_instance_of(Person) }
30
-
31
- context 'links' do
32
- it 'respects using' do
33
- expect(address.links.super).to be_kind_of(Person)
34
- expect(address.links.super.object).to be(resource.manager)
35
- expect(address.links.caretaker.object).to be(resource.custodian)
36
- end
37
-
38
- end
39
30
  end
40
31
 
41
32
 
@@ -52,16 +43,6 @@ describe Praxis::MediaType do
52
43
  subject(:address_klass) { address.class }
53
44
 
54
45
  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
46
  context 'in praxis v1.0 and beyond' do
66
47
  it 'should be a kind of Praxis::MediaTypeIdentifier' do
67
48
  pending('interface-breaking change') if Praxis::VERSION =~ /^0/
@@ -72,36 +53,6 @@ describe Praxis::MediaType do
72
53
 
73
54
  its(:description) { should be_kind_of(String) }
74
55
 
75
- context 'links' do
76
- context 'with a custom links attribute' do
77
- subject(:person) { Person.new(owner_resource) }
78
-
79
- its(:links) { should be_kind_of(Array) }
80
- its(:links) { should eq(owner_resource.links) }
81
- end
82
-
83
- context 'using the links DSL' do
84
- subject(:address) { Address.new(resource) }
85
- its(:links) { should be_kind_of(Address::Links) }
86
-
87
- it 'inherits types appropriately' do
88
- links_attribute = Address::Links.attributes
89
- expect(links_attribute[:owner].type).to be(Person)
90
- expect(links_attribute[:super].type).to be(Person)
91
- expect(links_attribute[:caretaker].type).to be(Person)
92
- end
93
-
94
- context 'loading returned values' do
95
- subject(:residents) { address.links.residents }
96
- let(:residents_summary_resource) do
97
- {href: "/people", size: 2}
98
- end
99
-
100
- its(:href) { should eq('/people') }
101
- its(:size) { should eq(2) }
102
- end
103
- end
104
- end
105
56
  end
106
57
 
107
58
  context "rendering" do
@@ -112,43 +63,8 @@ describe Praxis::MediaType do
112
63
  its([:owner]) { should eq(Person.dump(owner_resource, view: :default)) }
113
64
  its([:fields]) { should eq(address.fields.dump ) }
114
65
 
115
- context 'links' do
116
- subject(:links) { output[:links] }
117
-
118
- its([:owner]) { should eq(Person.dump(owner_resource, view: :link)) }
119
- its([:super]) { should eq(Person.dump(manager_resource, view: :link)) }
120
-
121
- context 'for a collection summary' do
122
- let(:volume) { Volume.example }
123
- let(:snapshots_summary) { volume.snapshots_summary }
124
- let(:output) { volume.render(view: :default) }
125
- subject { links[:snapshots] }
126
-
127
- its([:name]) { should eq(snapshots_summary.name) }
128
- its([:size]) { should eq(snapshots_summary.size) }
129
- its([:href]) { should eq(snapshots_summary.href) }
130
- end
131
- end
132
-
133
-
134
66
  end
135
67
 
136
- context '.example' do
137
- subject(:example) { Address.example }
138
-
139
- its('links.owner') { should be(example.owner) }
140
- its('links.super') { should be(example.object.manager) }
141
-
142
- it 'does not respond to non-top-level attributes from links' do
143
- expect { example.super }.to raise_error(NoMethodError)
144
- end
145
-
146
- it 'responds to non-top-level attributes from links on its inner Struct' do
147
- expect(example.links.super).to be(example.object.manager)
148
- end
149
- end
150
-
151
-
152
68
  context 'describing' do
153
69
 
154
70
  subject(:described){ Address.describe }
@@ -171,10 +87,10 @@ describe Praxis::MediaType do
171
87
  its([:name]) { should eq(Address.name) }
172
88
  its([:identifier]) { should eq(Address.identifier.to_s) }
173
89
  it 'should include the defined views' do
174
- expect( subject[:views].keys ).to match_array([:default, :master, :link])
90
+ expect( subject[:views].keys ).to match_array([:default, :master])
175
91
  end
176
92
  it 'should include the defined attributes' do
177
- expect( subject[:attributes].keys ).to match_array([:id, :name, :owner, :custodian, :residents, :residents_summary, :links, :fields])
93
+ expect( subject[:attributes].keys ).to match_array([:id, :name, :owner, :custodian, :residents, :residents_summary, :fields])
178
94
  end
179
95
  end
180
96
 
@@ -192,56 +108,6 @@ describe Praxis::MediaType do
192
108
 
193
109
  subject(:output) { field_resolver.resolve(User,fields) }
194
110
 
195
-
196
- it 'merges link stuff in properly' do
197
- expect(output).to_not have_key(:links)
198
- expect(output).to have_key(:primary_blog)
199
-
200
- expect(output[:primary_blog]).to eq({href: true})
201
- end
202
-
203
- it 'resolves link aliases (from link ... using:)' do
204
- expect(output).to have_key(:posts_summary)
205
- expect(output[:posts_summary]).to eq({href: true})
206
- end
207
-
208
- context 'merging top-level attributes with those from links' do
209
- let(:user_view) { User.views[:extended] }
210
-
211
- subject(:primary_blog_output) { output[:primary_blog] }
212
- it 'merges them' do
213
- expected = {
214
- href: true,
215
- id: true,
216
- name: true,
217
- description: true
218
- }
219
- expect(primary_blog_output).to eq(expected)
220
- end
221
- end
222
-
223
- context 'deep-merging fields' do
224
- let(:fields) do
225
- {
226
- primary_blog: {
227
- owner: { first: true, last: true }
228
- },
229
- links: {
230
- primary_blog: {
231
- owner: { href: true }
232
- }
233
- }
234
- }
235
- end
236
-
237
- it 'does a deep-merge for sub-attributes' do
238
- expected = {
239
- owner: {first: true, last: true, href: true}
240
- }
241
- expect(output[:primary_blog]).to eq(expected)
242
- end
243
- end
244
-
245
111
  context 'resolving collections' do
246
112
  let(:fields) { {:id=>true, :posts=>[{:href=>true}]}}
247
113
  it 'strips arrays from the incoming fields' do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Praxis::MiddlewareApp do
4
4
 
5
5
  let(:init_args){ { root: 'here'} }
6
- let(:middleware) { Praxis::MiddlewareApp.for( init_args ) }
6
+ let(:middleware) { Praxis::MiddlewareApp.for( **init_args ) }
7
7
  let(:instance){ middleware.new(target)}
8
8
 
9
9
  context '.for' do
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Praxis::Request do
4
4
  let(:path) { '/instances/1?junk=foo&api_version=1.0' }
5
- let(:rack_input) { StringIO.new('something=given') }
6
- let(:env_content_type){ 'application/x-www-form-urlencoded' }
5
+ let(:rack_input) { StringIO.new('{"something": "given"}') }
6
+ let(:env_content_type){ 'application/json' }
7
7
  let(:env) do
8
8
  env = Rack::MockRequest.env_for(path)
9
9
  env['rack.input'] = rack_input
@@ -192,7 +192,7 @@ describe Praxis::Request do
192
192
  end
193
193
 
194
194
  context '#validate_payload' do
195
- before { request.load_payload('') }
195
+ before { request.load_payload('{}') }
196
196
  it 'should validate payload' do
197
197
  expect(request.payload).to receive(:validate).and_return([])
198
198
  request.validate_payload(context[:payload])
@@ -208,22 +208,11 @@ describe Praxis::Request do
208
208
  let(:load_context){ context[:payload] }
209
209
  let(:parsed_result){ double("parsed") }
210
210
 
211
- before do
212
- Praxis::Application.instance.handler 'xml', Praxis::Handlers::XML
213
- end
214
-
215
211
  after do
216
212
  expect(request.action.payload).to receive(:load).with(parsed_result, load_context, content_type: request.content_type.to_s )
217
213
  request.load_payload( load_context )
218
214
  end
219
215
 
220
- context 'that is url-encoded' do
221
- let(:env_content_type){ 'application/x-www-form-urlencoded' }
222
- let(:parsed_result) { {"something" => "given"} }
223
-
224
- it 'decodes it the www-form handler' do end
225
- end
226
-
227
216
  context 'that is json encoded' do
228
217
  let(:rack_input) { StringIO.new('{"one":1,"sub_hash":{"first":"hello"}}') }
229
218
  let(:env_content_type){ 'application/json' }
@@ -231,14 +220,6 @@ describe Praxis::Request do
231
220
 
232
221
  it 'decodes using the JSON handler' do end
233
222
  end
234
- context 'that is xml encoded' do
235
- let(:rack_input) { StringIO.new('<hash><one type="integer">1</one><sub_hash><first>hello</first></sub_hash></hash>') }
236
- let(:env_content_type) { 'application/xml' }
237
- let(:parsed_result) { Praxis::Handlers::XML.new.parse(request.raw_payload) }
238
-
239
- it 'decodes using the XML handler' do end
240
- end
241
-
242
223
  end
243
224
  end
244
225
  end
@@ -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
 
@@ -137,7 +137,7 @@ describe Praxis::ResourceDefinition do
137
137
  it 'are applied to actions' do
138
138
  action = resource_definition.actions[:show]
139
139
  expect(action.params.attributes).to have_key(:id)
140
- expect(action.routes.first.path.to_s).to eq '/api/:base_param/people/:id'
140
+ expect(action.route.path.to_s).to eq '/api/:base_param/people/:id'
141
141
  end
142
142
 
143
143
  context 'includes base_params from the APIDefinition' do
@@ -448,7 +448,7 @@ describe Praxis::ResponseDefinition do
448
448
  context 'with legacy multipart response' do
449
449
  subject(:response) { Praxis::Responses::Ok.new(status: response_status, headers: response_headers) }
450
450
 
451
- 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'},**{}) }
452
452
 
453
453
  before do
454
454
  response_definition.parts like: :ok, media_type: 'application/special'
@@ -463,7 +463,7 @@ describe Praxis::ResponseDefinition do
463
463
  end
464
464
 
465
465
  context 'with invalid part' do
466
- let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, "Location" => "somewhere"},{}) }
466
+ let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, "Location" => "somewhere"}) }
467
467
 
468
468
  it 'validates' do
469
469
  expect {
@@ -494,6 +494,7 @@ describe Praxis::ResponseDefinition do
494
494
  let(:location) { %r{/my/url/} }
495
495
  let(:headers) { {'Header1' => 'Value1'} }
496
496
  let(:parts) { nil }
497
+ let(:parts_block) { nil }
497
498
 
498
499
  let(:response) do
499
500
  Praxis::ResponseDefinition.new(:custom) do
@@ -505,28 +506,26 @@ describe Praxis::ResponseDefinition do
505
506
  before do
506
507
  response.description(description) if description
507
508
  response.location(location) if location
508
- 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
509
512
  response.headers(headers) if headers
510
513
  end
511
514
 
512
515
  context 'for a definition with a media type' do
513
516
  let(:media_type) { Instance }
514
- subject(:payload) { output[:payload] }
517
+ subject(:payload) { output[:payload][:type] }
515
518
 
516
519
  before do
517
520
  response.media_type Instance
518
521
  end
519
-
520
522
  its([:name]) { should eq 'Instance' }
521
523
  context 'examples' do
522
524
  subject(:examples) { payload[:examples] }
523
525
  its(['json', :content_type]) { should eq('application/vnd.acme.instance+json') }
524
- its(['xml', :content_type]) { should eq('application/vnd.acme.instance+xml') }
525
526
 
526
527
  it 'properly encodes the example bodies' do
527
- json = Praxis::Application.instance.handlers['json'].parse(examples['json'][:body])
528
- xml = Praxis::Application.instance.handlers['xml'].parse(examples['xml'][:body])
529
- expect(json).to eq xml
528
+ expect(JSON.parse(examples['json'][:body])).to be_kind_of(Hash)
530
529
  end
531
530
 
532
531
  end
@@ -539,7 +538,6 @@ describe Praxis::ResponseDefinition do
539
538
 
540
539
  it 'still renders examples but as pure handler types for contents' do
541
540
  expect(subject['json'][:content_type]).to eq('application/json')
542
- expect(subject['xml'][:content_type]).to eq('application/xml')
543
541
  end
544
542
  end
545
543
 
@@ -568,11 +566,13 @@ describe Praxis::ResponseDefinition do
568
566
  end
569
567
 
570
568
  it{ should be_kind_of(::Hash) }
571
- its([:payload]){ should == {id: 'Praxis-SimpleMediaType', name: 'Praxis::SimpleMediaType', family: 'string', identifier: 'foobar' } }
569
+ it 'has the right type info' do
570
+ expect(subject[:payload][:type]).to match(id: 'Praxis-SimpleMediaType', name: 'Praxis::SimpleMediaType', family: 'string', identifier: 'foobar')
571
+ end
572
572
  its([:status]){ should == 200 }
573
573
  end
574
574
  context 'using a full response definition block' do
575
- let(:parts) do
575
+ let(:parts_block) do
576
576
  Proc.new do
577
577
  status 234
578
578
  media_type 'custom_media'
@@ -584,7 +584,9 @@ describe Praxis::ResponseDefinition do
584
584
  end
585
585
 
586
586
  it{ should be_kind_of(::Hash) }
587
- its([:payload]) { should == {id: 'Praxis-SimpleMediaType', name: 'Praxis::SimpleMediaType', family: 'string', identifier: 'custom_media'} }
587
+ it 'has the right type info' do
588
+ expect(subject[:payload][:type]).to match(id: 'Praxis-SimpleMediaType', name: 'Praxis::SimpleMediaType', family: 'string', identifier: 'custom_media')
589
+ end
588
590
  its([:status]) { should == 234 }
589
591
  end
590
592
  end
@@ -117,7 +117,7 @@ describe Praxis::Response do
117
117
  end
118
118
 
119
119
  context 'multipart responses' do
120
- 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"}) }
121
121
 
122
122
  context '#add_part' do
123
123
 
@@ -5,21 +5,19 @@ describe Praxis::Route do
5
5
  let(:verb) { 'GET' }
6
6
  let(:path) { '/base/stuff' }
7
7
  let(:prefixed_path) { '/stuff' }
8
- let(:name) { nil }
9
8
  let(:version) { '1.0' }
10
9
  let(:options) { {} }
11
10
 
12
- subject(:route) { Praxis::Route.new(verb, path, version, name: name, prefixed_path: prefixed_path, **options) }
11
+ subject(:route) { Praxis::Route.new(verb, path, version, prefixed_path: prefixed_path, **options) }
13
12
 
14
13
  its(:verb) { should be(verb) }
15
14
  its(:path) { should be(path) }
16
- its(:name) { should be(name) }
17
15
  its(:version) { should be(version) }
18
16
  its(:prefixed_path) { should eq(prefixed_path) }
19
17
  its(:options) { should eq(options) }
20
18
 
21
19
  it 'defaults version to "n/a"' do
22
- route = Praxis::Route.new(verb, path, name: name, **options)
20
+ route = Praxis::Route.new(verb, path, **options)
23
21
  expect(route.version).to eq('n/a')
24
22
  end
25
23
 
@@ -27,11 +25,6 @@ describe Praxis::Route do
27
25
  subject(:description) { route.describe }
28
26
  it { should eq({verb:verb, path:path , version:version}) }
29
27
 
30
- context 'with a named route' do
31
- let(:name) { :stuff }
32
- its([:name]) { should eq(name) }
33
- end
34
-
35
28
  context 'with options' do
36
29
  let(:options) { {option: 'value'} }
37
30
  its([:options]) { should eq(options) }
@@ -6,7 +6,7 @@ describe Praxis::Router do
6
6
  let(:action){ double("action", resource_definition: resource_definition ) }
7
7
  let(:target){ double("target", action: action ) }
8
8
  let(:args){ {version: "1.0"} }
9
- subject(:matcher){ Praxis::Router::VersionMatcher.new(target,args) }
9
+ subject(:matcher){ Praxis::Router::VersionMatcher.new(target,**args) }
10
10
 
11
11
  context '.initialize' do
12
12
  let(:args){ {} }
@@ -43,26 +43,17 @@ describe Praxis::RoutingConfig do
43
43
  let(:options) { {} }
44
44
  let(:base_path){ '/api' }
45
45
  let(:route) { routing_config.add_route 'GET', path, **options}
46
-
46
+
47
47
  it 'returns a corresponding Praxis::Route' do
48
48
  expect(route).to be_kind_of(Praxis::Route)
49
49
  end
50
50
 
51
- it 'appends the Route to the set of routes' do
52
- expect(routing_config.routes).to include(route)
51
+ it 'sets the Route to its route' do
52
+ expect(route).to eq(routing_config.route)
53
53
  end
54
54
 
55
55
  context 'passing options' do
56
- let(:options){ {name: 'alternative', except: '/special' } }
57
-
58
- it 'uses :name to name the route' do
59
- expect(route.name).to eq('alternative')
60
- end
61
-
62
- it 'does NOT pass the name option down to mustermann' do
63
- expect(Mustermann).to receive(:new).with(base_path + path, hash_excluding({name: 'alternative'}))
64
- expect(route.name).to eq('alternative')
65
- end
56
+ let(:options){ { except: '/special' } }
66
57
 
67
58
  it 'passes them through the underlying mustermann object (telling it to ignore unknown ones)' do
68
59
  expect(Mustermann).to receive(:new).with(base_path + path, hash_including(ignore_unknown_options: true, except: '/special'))