praxis 2.0.pre.4 → 2.0.pre.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +0 -1
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +31 -0
  5. data/Gemfile +1 -1
  6. data/Guardfile +2 -1
  7. data/Rakefile +1 -7
  8. data/TODO.md +28 -0
  9. data/lib/api_browser/package-lock.json +7110 -0
  10. data/lib/praxis.rb +7 -4
  11. data/lib/praxis/action_definition.rb +9 -16
  12. data/lib/praxis/api_general_info.rb +21 -0
  13. data/lib/praxis/application.rb +1 -2
  14. data/lib/praxis/bootloader_stages/routing.rb +2 -4
  15. data/lib/praxis/docs/generator.rb +11 -6
  16. data/lib/praxis/docs/open_api_generator.rb +255 -0
  17. data/lib/praxis/docs/openapi/info_object.rb +39 -0
  18. data/lib/praxis/docs/openapi/media_type_object.rb +59 -0
  19. data/lib/praxis/docs/openapi/operation_object.rb +40 -0
  20. data/lib/praxis/docs/openapi/parameter_object.rb +69 -0
  21. data/lib/praxis/docs/openapi/paths_object.rb +55 -0
  22. data/lib/praxis/docs/openapi/request_body_object.rb +51 -0
  23. data/lib/praxis/docs/openapi/response_object.rb +63 -0
  24. data/lib/praxis/docs/openapi/responses_object.rb +44 -0
  25. data/lib/praxis/docs/openapi/schema_object.rb +87 -0
  26. data/lib/praxis/docs/openapi/server_object.rb +24 -0
  27. data/lib/praxis/docs/openapi/tag_object.rb +21 -0
  28. data/lib/praxis/extensions/attribute_filtering.rb +2 -0
  29. data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +148 -157
  30. data/lib/praxis/extensions/attribute_filtering/active_record_patches.rb +15 -0
  31. data/lib/praxis/extensions/attribute_filtering/active_record_patches/5x.rb +90 -0
  32. data/lib/praxis/extensions/attribute_filtering/active_record_patches/6_0.rb +68 -0
  33. data/lib/praxis/extensions/attribute_filtering/active_record_patches/6_1_plus.rb +58 -0
  34. data/lib/praxis/extensions/attribute_filtering/filter_tree_node.rb +35 -0
  35. data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +12 -24
  36. data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +3 -2
  37. data/lib/praxis/extensions/field_selection/active_record_query_selector.rb +7 -9
  38. data/lib/praxis/extensions/field_selection/field_selector.rb +4 -0
  39. data/lib/praxis/extensions/field_selection/sequel_query_selector.rb +6 -9
  40. data/lib/praxis/extensions/pagination.rb +130 -0
  41. data/lib/praxis/extensions/pagination/active_record_pagination_handler.rb +42 -0
  42. data/lib/praxis/extensions/pagination/header_generator.rb +70 -0
  43. data/lib/praxis/extensions/pagination/ordering_params.rb +238 -0
  44. data/lib/praxis/extensions/pagination/pagination_handler.rb +68 -0
  45. data/lib/praxis/extensions/pagination/pagination_params.rb +378 -0
  46. data/lib/praxis/extensions/pagination/sequel_pagination_handler.rb +45 -0
  47. data/lib/praxis/handlers/json.rb +2 -0
  48. data/lib/praxis/handlers/www_form.rb +5 -0
  49. data/lib/praxis/handlers/{xml.rb → xml-sample.rb} +6 -0
  50. data/lib/praxis/links.rb +4 -0
  51. data/lib/praxis/mapper/active_model_compat.rb +23 -5
  52. data/lib/praxis/mapper/resource.rb +16 -9
  53. data/lib/praxis/mapper/selector_generator.rb +0 -4
  54. data/lib/praxis/mapper/sequel_compat.rb +1 -0
  55. data/lib/praxis/media_type.rb +1 -56
  56. data/lib/praxis/multipart/part.rb +5 -2
  57. data/lib/praxis/plugins/mapper_plugin.rb +1 -1
  58. data/lib/praxis/plugins/pagination_plugin.rb +71 -0
  59. data/lib/praxis/resource_definition.rb +4 -12
  60. data/lib/praxis/response_definition.rb +1 -1
  61. data/lib/praxis/route.rb +2 -4
  62. data/lib/praxis/routing_config.rb +4 -8
  63. data/lib/praxis/tasks/api_docs.rb +23 -0
  64. data/lib/praxis/tasks/routes.rb +10 -15
  65. data/lib/praxis/types/media_type_common.rb +10 -0
  66. data/lib/praxis/types/multipart_array.rb +62 -0
  67. data/lib/praxis/validation_handler.rb +1 -2
  68. data/lib/praxis/version.rb +1 -1
  69. data/praxis.gemspec +4 -5
  70. data/spec/functional_spec.rb +9 -6
  71. data/spec/praxis/action_definition_spec.rb +4 -16
  72. data/spec/praxis/api_general_info_spec.rb +6 -6
  73. data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +304 -0
  74. data/spec/praxis/extensions/attribute_filtering/filter_tree_node_spec.rb +39 -0
  75. data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +140 -0
  76. data/spec/praxis/extensions/field_expansion_spec.rb +6 -24
  77. data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +15 -11
  78. data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +4 -3
  79. data/spec/praxis/extensions/pagination/active_record_pagination_handler_spec.rb +130 -0
  80. data/spec/praxis/extensions/{field_selection/support → support}/spec_resources_active_model.rb +45 -2
  81. data/spec/praxis/extensions/{field_selection/support → support}/spec_resources_sequel.rb +0 -0
  82. data/spec/praxis/media_type_spec.rb +5 -129
  83. data/spec/praxis/request_spec.rb +3 -22
  84. data/spec/praxis/resource_definition_spec.rb +1 -1
  85. data/spec/praxis/response_definition_spec.rb +8 -9
  86. data/spec/praxis/route_spec.rb +2 -9
  87. data/spec/praxis/routing_config_spec.rb +4 -13
  88. data/spec/praxis/types/multipart_array_spec.rb +4 -21
  89. data/spec/spec_app/config/environment.rb +0 -2
  90. data/spec/spec_app/design/api.rb +7 -1
  91. data/spec/spec_app/design/media_types/instance.rb +0 -8
  92. data/spec/spec_app/design/media_types/volume.rb +0 -12
  93. data/spec/spec_app/design/resources/instances.rb +1 -2
  94. data/spec/spec_helper.rb +6 -0
  95. data/spec/support/spec_media_types.rb +0 -73
  96. metadata +51 -49
  97. data/spec/praxis/handlers/xml_spec.rb +0 -177
  98. data/spec/praxis/links_spec.rb +0 -68
@@ -36,6 +36,7 @@ def create_tables
36
36
  create_table :active_taggings do |table|
37
37
  table.column :book_id, :integer
38
38
  table.column :tag_id, :integer
39
+ table.column :label, :string, null: true
39
40
  end
40
41
  end
41
42
  end
@@ -48,8 +49,12 @@ class ActiveBook < ActiveRecord::Base
48
49
 
49
50
  belongs_to :category, class_name: 'ActiveCategory', foreign_key: :category_uuid, primary_key: :uuid
50
51
  belongs_to :author, class_name: 'ActiveAuthor'
52
+
51
53
  has_many :taggings, class_name: 'ActiveTagging', foreign_key: :book_id
54
+ has_many :primary_taggings, lambda { where(label: 'primary')}, class_name: 'ActiveTagging', foreign_key: :book_id
55
+
52
56
  has_many :tags, class_name: 'ActiveTag', through: :taggings
57
+ has_many :primary_tags, class_name: 'ActiveTag', through: :primary_taggings, source: :tag
53
58
  end
54
59
 
55
60
  class ActiveAuthor < ActiveRecord::Base
@@ -64,6 +69,8 @@ end
64
69
 
65
70
  class ActiveTag < ActiveRecord::Base
66
71
  include Praxis::Mapper::ActiveModelCompat
72
+ has_many :taggings, class_name: 'ActiveTagging', foreign_key: :tag_id
73
+ has_many :books, class_name: 'ActiveBook', through: :taggings, source: :book
67
74
  end
68
75
 
69
76
  class ActiveTagging < ActiveRecord::Base
@@ -94,6 +101,26 @@ end
94
101
  class ActiveBookResource < ActiveBaseResource
95
102
  model ActiveBook
96
103
 
104
+ filters_mapping(
105
+ id: :id,
106
+ category_uuid: :category_uuid,
107
+ 'fake_nested.name': 'simple_name',
108
+ 'name': 'simple_name',
109
+ 'name_is_not': lambda do |spec| # Silly way to use a proc, but good enough for testing
110
+ { name: :simple_name, value: spec[:value] , op: '!=' } # Can be an array for multiple conditions as well
111
+ end,
112
+ 'author.id': 'author.id',
113
+ 'author.name': 'author.name',
114
+ 'taggings.label': 'taggings.label',
115
+ 'taggings.tag_id': 'taggings.tag_id',
116
+ 'taggings.tag.taggings.tag_id': 'taggings.tag.taggings.tag_id',
117
+ 'tags.name': 'tags.name',
118
+ 'primary_tags.name': 'primary_tags.name',
119
+ 'category.name': 'category.name',
120
+ 'category.books.name': 'category.books.simple_name',
121
+ 'category.books.taggings.tag_id': 'category.books.taggings.tag_id',
122
+ 'category.books.taggings.label': 'category.books.taggings.label',
123
+ )
97
124
  # Forces to add an extra column (added_column)...and yet another (author_id) that will serve
98
125
  # to check that if that's already automatically added due to an association, it won't interfere or duplicate
99
126
  property :author, dependencies: [:author, :added_column, :author_id]
@@ -108,23 +135,39 @@ def seed_data
108
135
 
109
136
  author1 = ActiveAuthor.create( id: 11, name: 'author1' )
110
137
  author2 = ActiveAuthor.create( id: 22, name: 'author2' )
138
+ author3 = ActiveAuthor.create( id: 33, name: nil )
111
139
 
112
140
  tag_blue = ActiveTag.create(id: 1 , name: 'blue' )
113
141
  tag_red = ActiveTag.create(id: 2 , name: 'red' )
142
+ tag_green = ActiveTag.create(id: 3 , name: 'green' )
114
143
 
115
144
  book1 = ActiveBook.create( id: 1 , simple_name: 'Book1', category_uuid: 'deadbeef1')
116
145
  book1.author = author1
117
146
  book1.category = cat1
118
147
  book1.save
119
- ActiveTagging.create(book: book1, tag: tag_blue)
148
+ ActiveTagging.create(book: book1, tag: tag_blue, label: 'primary')
120
149
  ActiveTagging.create(book: book1, tag: tag_red)
150
+ ActiveTagging.create(book: book1, tag: tag_green, label: 'primary')
121
151
 
122
152
 
123
153
  book2 = ActiveBook.create( id: 2 , simple_name: 'Book2', category_uuid: 'deadbeef1')
124
154
  book2.author = author2
125
155
  book2.category = cat2
126
156
  book2.save
127
- ActiveTagging.create(book: book2, tag: tag_red)
157
+ ActiveTagging.create(book: book2, tag: tag_red, label: 'primary')
158
+
159
+ book3 = ActiveBook.create( id: 3 , simple_name: 'Book3', category_uuid: 'deadbeef1')
160
+ book3.author = author3
161
+ book3.save
162
+ ActiveTagging.create(book: book3, tag: tag_red, label: 'primary')
163
+
164
+ # More stuff
165
+
166
+ 10.times do |i|
167
+ bid = 1000+i
168
+ ActiveBook.create( id: bid , simple_name: "Book#{bid}")
169
+ end
170
+
128
171
  end
129
172
 
130
173
  seed_data
@@ -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
 
@@ -62,36 +53,6 @@ describe Praxis::MediaType do
62
53
 
63
54
  its(:description) { should be_kind_of(String) }
64
55
 
65
- context 'links' do
66
- context 'with a custom links attribute' do
67
- subject(:person) { Person.new(owner_resource) }
68
-
69
- its(:links) { should be_kind_of(Array) }
70
- its(:links) { should eq(owner_resource.links) }
71
- end
72
-
73
- context 'using the links DSL' do
74
- subject(:address) { Address.new(resource) }
75
- its(:links) { should be_kind_of(Address::Links) }
76
-
77
- it 'inherits types appropriately' do
78
- links_attribute = Address::Links.attributes
79
- expect(links_attribute[:owner].type).to be(Person)
80
- expect(links_attribute[:super].type).to be(Person)
81
- expect(links_attribute[:caretaker].type).to be(Person)
82
- end
83
-
84
- context 'loading returned values' do
85
- subject(:residents) { address.links.residents }
86
- let(:residents_summary_resource) do
87
- {href: "/people", size: 2}
88
- end
89
-
90
- its(:href) { should eq('/people') }
91
- its(:size) { should eq(2) }
92
- end
93
- end
94
- end
95
56
  end
96
57
 
97
58
  context "rendering" do
@@ -102,43 +63,8 @@ describe Praxis::MediaType do
102
63
  its([:owner]) { should eq(Person.dump(owner_resource, view: :default)) }
103
64
  its([:fields]) { should eq(address.fields.dump ) }
104
65
 
105
- context 'links' do
106
- subject(:links) { output[:links] }
107
-
108
- its([:owner]) { should eq(Person.dump(owner_resource, view: :link)) }
109
- its([:super]) { should eq(Person.dump(manager_resource, view: :link)) }
110
-
111
- context 'for a collection summary' do
112
- let(:volume) { Volume.example }
113
- let(:snapshots_summary) { volume.snapshots_summary }
114
- let(:output) { volume.render(view: :default) }
115
- subject { links[:snapshots] }
116
-
117
- its([:name]) { should eq(snapshots_summary.name) }
118
- its([:size]) { should eq(snapshots_summary.size) }
119
- its([:href]) { should eq(snapshots_summary.href) }
120
- end
121
- end
122
-
123
-
124
- end
125
-
126
- context '.example' do
127
- subject(:example) { Address.example }
128
-
129
- its('links.owner') { should be(example.owner) }
130
- its('links.super') { should be(example.object.manager) }
131
-
132
- it 'does not respond to non-top-level attributes from links' do
133
- expect { example.super }.to raise_error(NoMethodError)
134
- end
135
-
136
- it 'responds to non-top-level attributes from links on its inner Struct' do
137
- expect(example.links.super).to be(example.object.manager)
138
- end
139
66
  end
140
67
 
141
-
142
68
  context 'describing' do
143
69
 
144
70
  subject(:described){ Address.describe }
@@ -161,10 +87,10 @@ describe Praxis::MediaType do
161
87
  its([:name]) { should eq(Address.name) }
162
88
  its([:identifier]) { should eq(Address.identifier.to_s) }
163
89
  it 'should include the defined views' do
164
- expect( subject[:views].keys ).to match_array([:default, :master, :link])
90
+ expect( subject[:views].keys ).to match_array([:default, :master])
165
91
  end
166
92
  it 'should include the defined attributes' do
167
- 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])
168
94
  end
169
95
  end
170
96
 
@@ -182,56 +108,6 @@ describe Praxis::MediaType do
182
108
 
183
109
  subject(:output) { field_resolver.resolve(User,fields) }
184
110
 
185
-
186
- it 'merges link stuff in properly' do
187
- expect(output).to_not have_key(:links)
188
- expect(output).to have_key(:primary_blog)
189
-
190
- expect(output[:primary_blog]).to eq({href: true})
191
- end
192
-
193
- it 'resolves link aliases (from link ... using:)' do
194
- expect(output).to have_key(:posts_summary)
195
- expect(output[:posts_summary]).to eq({href: true})
196
- end
197
-
198
- context 'merging top-level attributes with those from links' do
199
- let(:user_view) { User.views[:extended] }
200
-
201
- subject(:primary_blog_output) { output[:primary_blog] }
202
- it 'merges them' do
203
- expected = {
204
- href: true,
205
- id: true,
206
- name: true,
207
- description: true
208
- }
209
- expect(primary_blog_output).to eq(expected)
210
- end
211
- end
212
-
213
- context 'deep-merging fields' do
214
- let(:fields) do
215
- {
216
- primary_blog: {
217
- owner: { first: true, last: true }
218
- },
219
- links: {
220
- primary_blog: {
221
- owner: { href: true }
222
- }
223
- }
224
- }
225
- end
226
-
227
- it 'does a deep-merge for sub-attributes' do
228
- expected = {
229
- owner: {first: true, last: true, href: true}
230
- }
231
- expect(output[:primary_blog]).to eq(expected)
232
- end
233
- end
234
-
235
111
  context 'resolving collections' do
236
112
  let(:fields) { {:id=>true, :posts=>[{:href=>true}]}}
237
113
  it 'strips arrays from the incoming fields' 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
@@ -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
@@ -514,22 +514,18 @@ describe Praxis::ResponseDefinition do
514
514
 
515
515
  context 'for a definition with a media type' do
516
516
  let(:media_type) { Instance }
517
- subject(:payload) { output[:payload] }
517
+ subject(:payload) { output[:payload][:type] }
518
518
 
519
519
  before do
520
520
  response.media_type Instance
521
521
  end
522
-
523
522
  its([:name]) { should eq 'Instance' }
524
523
  context 'examples' do
525
524
  subject(:examples) { payload[:examples] }
526
525
  its(['json', :content_type]) { should eq('application/vnd.acme.instance+json') }
527
- its(['xml', :content_type]) { should eq('application/vnd.acme.instance+xml') }
528
526
 
529
527
  it 'properly encodes the example bodies' do
530
- json = Praxis::Application.instance.handlers['json'].parse(examples['json'][:body])
531
- xml = Praxis::Application.instance.handlers['xml'].parse(examples['xml'][:body])
532
- expect(json).to eq xml
528
+ expect(JSON.parse(examples['json'][:body])).to be_kind_of(Hash)
533
529
  end
534
530
 
535
531
  end
@@ -542,7 +538,6 @@ describe Praxis::ResponseDefinition do
542
538
 
543
539
  it 'still renders examples but as pure handler types for contents' do
544
540
  expect(subject['json'][:content_type]).to eq('application/json')
545
- expect(subject['xml'][:content_type]).to eq('application/xml')
546
541
  end
547
542
  end
548
543
 
@@ -571,7 +566,9 @@ describe Praxis::ResponseDefinition do
571
566
  end
572
567
 
573
568
  it{ should be_kind_of(::Hash) }
574
- 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
575
572
  its([:status]){ should == 200 }
576
573
  end
577
574
  context 'using a full response definition block' do
@@ -587,7 +584,9 @@ describe Praxis::ResponseDefinition do
587
584
  end
588
585
 
589
586
  it{ should be_kind_of(::Hash) }
590
- 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
591
590
  its([:status]) { should == 234 }
592
591
  end
593
592
  end
@@ -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) }
@@ -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'))