brainstem 1.4.1 → 2.0.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -0
- data/README.md +119 -0
- data/docs/api_doc_generator.markdown +45 -4
- data/docs/brainstem_executable.markdown +1 -1
- data/docs/oas_2_docgen.png +0 -0
- data/docs/oas_2_docgen_ascii.txt +78 -0
- data/lib/brainstem/api_docs.rb +23 -9
- data/lib/brainstem/api_docs/abstract_collection.rb +0 -13
- data/lib/brainstem/api_docs/atlas.rb +0 -14
- data/lib/brainstem/api_docs/builder.rb +0 -14
- data/lib/brainstem/api_docs/controller.rb +7 -16
- data/lib/brainstem/api_docs/controller_collection.rb +0 -3
- data/lib/brainstem/api_docs/endpoint.rb +73 -19
- data/lib/brainstem/api_docs/endpoint_collection.rb +0 -7
- data/lib/brainstem/api_docs/formatters/abstract_formatter.rb +0 -2
- data/lib/brainstem/api_docs/formatters/markdown/controller_formatter.rb +1 -9
- data/lib/brainstem/api_docs/formatters/markdown/endpoint_collection_formatter.rb +1 -9
- data/lib/brainstem/api_docs/formatters/markdown/endpoint_formatter.rb +39 -24
- data/lib/brainstem/api_docs/formatters/markdown/helper.rb +0 -13
- data/lib/brainstem/api_docs/formatters/markdown/presenter_formatter.rb +22 -35
- data/lib/brainstem/api_docs/formatters/open_api_specification/helper.rb +66 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter.rb +57 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter.rb +311 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb +197 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter.rb +60 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb +162 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter.rb +126 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter.rb +132 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter.rb +99 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb +123 -0
- data/lib/brainstem/api_docs/introspectors/abstract_introspector.rb +0 -7
- data/lib/brainstem/api_docs/introspectors/rails_introspector.rb +1 -20
- data/lib/brainstem/api_docs/presenter.rb +21 -27
- data/lib/brainstem/api_docs/presenter_collection.rb +1 -11
- data/lib/brainstem/api_docs/resolver.rb +1 -8
- data/lib/brainstem/api_docs/sinks/abstract_sink.rb +0 -4
- data/lib/brainstem/api_docs/sinks/controller_presenter_multifile_sink.rb +0 -9
- data/lib/brainstem/api_docs/sinks/open_api_specification_sink.rb +234 -0
- data/lib/brainstem/api_docs/sinks/stdout_sink.rb +0 -5
- data/lib/brainstem/cli.rb +0 -13
- data/lib/brainstem/cli/abstract_command.rb +0 -7
- data/lib/brainstem/cli/generate_api_docs_command.rb +48 -24
- data/lib/brainstem/concerns/controller_dsl.rb +288 -145
- data/lib/brainstem/concerns/formattable.rb +0 -5
- data/lib/brainstem/concerns/optional.rb +0 -1
- data/lib/brainstem/concerns/presenter_dsl.rb +2 -21
- data/lib/brainstem/dsl/configuration.rb +0 -11
- data/lib/brainstem/presenter.rb +0 -4
- data/lib/brainstem/version.rb +1 -1
- data/spec/brainstem/api_docs/abstract_collection_spec.rb +0 -11
- data/spec/brainstem/api_docs/atlas_spec.rb +0 -6
- data/spec/brainstem/api_docs/builder_spec.rb +0 -4
- data/spec/brainstem/api_docs/controller_collection_spec.rb +0 -2
- data/spec/brainstem/api_docs/controller_spec.rb +29 -18
- data/spec/brainstem/api_docs/endpoint_collection_spec.rb +0 -6
- data/spec/brainstem/api_docs/endpoint_spec.rb +343 -13
- data/spec/brainstem/api_docs/formatters/abstract_formatter_spec.rb +0 -2
- data/spec/brainstem/api_docs/formatters/markdown/controller_formatter_spec.rb +0 -1
- data/spec/brainstem/api_docs/formatters/markdown/endpoint_collection_formatter_spec.rb +0 -5
- data/spec/brainstem/api_docs/formatters/markdown/endpoint_formatter_spec.rb +94 -8
- data/spec/brainstem/api_docs/formatters/markdown/helper_spec.rb +0 -8
- data/spec/brainstem/api_docs/formatters/markdown/presenter_formatter_spec.rb +0 -7
- data/spec/brainstem/api_docs/formatters/open_api_specification/helper_spec.rb +210 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter_spec.rb +81 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter_spec.rb +672 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb +335 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb +59 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb +308 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb +89 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb +430 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb +190 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter_spec.rb +217 -0
- data/spec/brainstem/api_docs/introspectors/abstract_introspector_spec.rb +0 -2
- data/spec/brainstem/api_docs/introspectors/rails_introspector_spec.rb +0 -2
- data/spec/brainstem/api_docs/presenter_collection_spec.rb +0 -2
- data/spec/brainstem/api_docs/presenter_spec.rb +58 -18
- data/spec/brainstem/api_docs/resolver_spec.rb +0 -1
- data/spec/brainstem/api_docs/sinks/controller_presenter_multifile_sink_spec.rb +0 -2
- data/spec/brainstem/api_docs/sinks/open_api_specification_sink_spec.rb +371 -0
- data/spec/brainstem/api_docs_spec.rb +2 -0
- data/spec/brainstem/cli/abstract_command_spec.rb +0 -4
- data/spec/brainstem/cli/generate_api_docs_command_spec.rb +53 -2
- data/spec/brainstem/concerns/controller_dsl_spec.rb +430 -64
- data/spec/brainstem/concerns/presenter_dsl_spec.rb +0 -20
- data/spec/brainstem/preloader_spec.rb +0 -7
- data/spec/brainstem/presenter_spec.rb +0 -1
- data/spec/dummy/rails.rb +0 -1
- data/spec/spec_helpers/db.rb +0 -1
- metadata +37 -2
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
require 'brainstem/api_docs'
|
|
2
2
|
require 'active_support/inflector/inflections'
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
module Brainstem
|
|
6
5
|
module Concerns
|
|
7
6
|
module Formattable
|
|
8
7
|
attr_writer :formatters
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
def valid_options
|
|
12
10
|
super | [ :formatters ]
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
|
|
16
13
|
def formatters
|
|
17
14
|
@formatters ||= ::Brainstem::ApiDocs::FORMATTERS[formatter_type]
|
|
18
15
|
end
|
|
19
16
|
|
|
20
|
-
|
|
21
17
|
def formatted_as(format, options = {})
|
|
22
18
|
formatters[format].call(self, options)
|
|
23
19
|
end
|
|
24
20
|
|
|
25
|
-
|
|
26
21
|
#
|
|
27
22
|
# Declares the type of formatter that should be used to format an entity
|
|
28
23
|
# of this class.
|
|
@@ -10,7 +10,6 @@ require 'brainstem/dsl/conditionals_block'
|
|
|
10
10
|
require 'brainstem/dsl/fields_block'
|
|
11
11
|
require 'brainstem/dsl/associations_block'
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
require 'active_support/core_ext/array/extract_options'
|
|
15
14
|
|
|
16
15
|
module Brainstem
|
|
@@ -70,7 +69,6 @@ module Brainstem
|
|
|
70
69
|
end
|
|
71
70
|
end
|
|
72
71
|
|
|
73
|
-
|
|
74
72
|
# @overload default_sort_order(sort_string)
|
|
75
73
|
# Sets a default sort order.
|
|
76
74
|
# @param [String] sort_string The sort order to apply by default
|
|
@@ -86,7 +84,6 @@ module Brainstem
|
|
|
86
84
|
configuration[:default_sort_order]
|
|
87
85
|
end
|
|
88
86
|
|
|
89
|
-
|
|
90
87
|
#
|
|
91
88
|
# @overload sort_order(name, order, options)
|
|
92
89
|
# @param [Symbol] name The name of the sort order.
|
|
@@ -121,7 +118,6 @@ module Brainstem
|
|
|
121
118
|
})
|
|
122
119
|
end
|
|
123
120
|
|
|
124
|
-
|
|
125
121
|
#
|
|
126
122
|
# @overload filter(name, type, options = {})
|
|
127
123
|
# @param [Symbol] name The name of the scope that may be applied as a
|
|
@@ -142,13 +138,8 @@ module Brainstem
|
|
|
142
138
|
# @yieldreturn [ActiveRecord::Relation] A new scope that filters the
|
|
143
139
|
# scope that was yielded.
|
|
144
140
|
#
|
|
145
|
-
def filter(name, type
|
|
146
|
-
if type.
|
|
147
|
-
options = type if options.blank?
|
|
148
|
-
type = DEFAULT_FILTER_DATA_TYPE
|
|
149
|
-
|
|
150
|
-
deprecated_type_warning
|
|
151
|
-
elsif type.to_s == 'array'
|
|
141
|
+
def filter(name, type, options = {}, &block)
|
|
142
|
+
if type.to_s == 'array'
|
|
152
143
|
options[:item_type] = options[:item_type].to_s.presence || DEFAULT_FILTER_DATA_TYPE
|
|
153
144
|
end
|
|
154
145
|
|
|
@@ -189,16 +180,6 @@ module Brainstem
|
|
|
189
180
|
|
|
190
181
|
DEFAULT_FILTER_DATA_TYPE = 'string'
|
|
191
182
|
private_constant :DEFAULT_FILTER_DATA_TYPE
|
|
192
|
-
|
|
193
|
-
def deprecated_type_warning
|
|
194
|
-
ActiveSupport::Deprecation.warn(
|
|
195
|
-
'Please specify the `type` of the filter as the second argument. If not specified, '\
|
|
196
|
-
'it will default to `:string`. This default behavior will be deprecated in the next major '\
|
|
197
|
-
'version and will need to be explicitly specified. '\
|
|
198
|
-
'e.g. `filter :status, :string, items: ["Started", "Completed"]`',
|
|
199
|
-
caller
|
|
200
|
-
)
|
|
201
|
-
end
|
|
202
183
|
end
|
|
203
184
|
end
|
|
204
185
|
end
|
|
@@ -60,7 +60,6 @@ module Brainstem
|
|
|
60
60
|
@storage[key] ||= InheritableAppendSet.new
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
64
63
|
#
|
|
65
64
|
# Marks a key in the configuration as nonheritable, which means that the key:
|
|
66
65
|
#
|
|
@@ -82,10 +81,8 @@ module Brainstem
|
|
|
82
81
|
self.nonheritable_keys << formatted_key unless self.nonheritable_keys.include?(formatted_key)
|
|
83
82
|
end
|
|
84
83
|
|
|
85
|
-
|
|
86
84
|
attr_accessor :nonheritable_keys
|
|
87
85
|
|
|
88
|
-
|
|
89
86
|
#
|
|
90
87
|
# Returns the keys in this configuration object that are visible to child
|
|
91
88
|
# configuration objects (i.e. heritable keys).
|
|
@@ -96,7 +93,6 @@ module Brainstem
|
|
|
96
93
|
keys - nonheritable_keys.to_a
|
|
97
94
|
end
|
|
98
95
|
|
|
99
|
-
|
|
100
96
|
#
|
|
101
97
|
# Returns a hash of this object's storage, less those pairs that are
|
|
102
98
|
# not visible to children.
|
|
@@ -107,7 +103,6 @@ module Brainstem
|
|
|
107
103
|
to_h.select {|k, v| keys_visible_to_children.include?(format_key(k)) }
|
|
108
104
|
end
|
|
109
105
|
|
|
110
|
-
|
|
111
106
|
#
|
|
112
107
|
# Returns the union of all keys in this configuration plus those that are
|
|
113
108
|
# heritable in the parent.
|
|
@@ -122,7 +117,6 @@ module Brainstem
|
|
|
122
117
|
end
|
|
123
118
|
end
|
|
124
119
|
|
|
125
|
-
|
|
126
120
|
#
|
|
127
121
|
# Returns a list of nonheritable keys for the parent configuration, if
|
|
128
122
|
# the parent configuration actually keeps track of it. Otherwise returns
|
|
@@ -139,7 +133,6 @@ module Brainstem
|
|
|
139
133
|
end
|
|
140
134
|
end
|
|
141
135
|
|
|
142
|
-
|
|
143
136
|
#
|
|
144
137
|
# Returns whether a key is nonheritable in this configuration object's
|
|
145
138
|
# parent configuration.
|
|
@@ -153,7 +146,6 @@ module Brainstem
|
|
|
153
146
|
parent_nonheritable_keys.include?(format_key(key.first))
|
|
154
147
|
end
|
|
155
148
|
|
|
156
|
-
|
|
157
149
|
#
|
|
158
150
|
# An inversion of +key_nonheritable_in_parent+. Returns true if the
|
|
159
151
|
# key is not marked as nonheritable in the parent configuration.
|
|
@@ -167,7 +159,6 @@ module Brainstem
|
|
|
167
159
|
!key_nonheritable_in_parent?(format_key(key.first))
|
|
168
160
|
end
|
|
169
161
|
|
|
170
|
-
|
|
171
162
|
#
|
|
172
163
|
# Returns a hash of this object's storage merged over the heritable pairs
|
|
173
164
|
# of its parent configurations.
|
|
@@ -182,7 +173,6 @@ module Brainstem
|
|
|
182
173
|
end
|
|
183
174
|
end
|
|
184
175
|
|
|
185
|
-
|
|
186
176
|
#
|
|
187
177
|
# Returns the value for the given key, or if it could not be found:
|
|
188
178
|
# - Raises a +KeyError+ if not passed a default or a block;
|
|
@@ -210,7 +200,6 @@ module Brainstem
|
|
|
210
200
|
end
|
|
211
201
|
end
|
|
212
202
|
|
|
213
|
-
|
|
214
203
|
def has_key?(key)
|
|
215
204
|
@storage.has_key?(key) ||
|
|
216
205
|
(@parent_configuration.has_key?(key) &&
|
data/lib/brainstem/presenter.rb
CHANGED
|
@@ -26,7 +26,6 @@ module Brainstem
|
|
|
26
26
|
@presents
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
#
|
|
31
30
|
# Returns the set of possible brainstem keys for the classes presented.
|
|
32
31
|
#
|
|
@@ -39,7 +38,6 @@ module Brainstem
|
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
# Return the second-to-last module in the name of this presenter, which Brainstem considers to be the 'namespace'.
|
|
44
42
|
# E.g., Api::V1::FooPresenter has a namespace of "V1".
|
|
45
43
|
# @return [String] The name of the second-to-last module containing this presenter.
|
|
@@ -410,12 +408,10 @@ module Brainstem
|
|
|
410
408
|
end
|
|
411
409
|
end
|
|
412
410
|
|
|
413
|
-
|
|
414
411
|
def self.presenter_collection
|
|
415
412
|
Brainstem.presenter_collection(namespace)
|
|
416
413
|
end
|
|
417
414
|
|
|
418
|
-
|
|
419
415
|
# @api protected
|
|
420
416
|
# Find the global presenter collection for our namespace.
|
|
421
417
|
def presenter_collection
|
data/lib/brainstem/version.rb
CHANGED
|
@@ -18,7 +18,6 @@ module Brainstem
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
describe "#<<" do
|
|
23
22
|
it "adds a member to the collection" do
|
|
24
23
|
subject << member
|
|
@@ -31,7 +30,6 @@ module Brainstem
|
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
|
|
35
33
|
describe "#each" do
|
|
36
34
|
it "iterates over each member" do
|
|
37
35
|
subject << members
|
|
@@ -39,13 +37,11 @@ module Brainstem
|
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
|
|
43
40
|
describe "iteration" do
|
|
44
41
|
before do
|
|
45
42
|
subject << member
|
|
46
43
|
end
|
|
47
44
|
|
|
48
|
-
|
|
49
45
|
describe "#filenames" do
|
|
50
46
|
it "maps all its members" do
|
|
51
47
|
stub(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -54,7 +50,6 @@ module Brainstem
|
|
|
54
50
|
end
|
|
55
51
|
end
|
|
56
52
|
|
|
57
|
-
|
|
58
53
|
describe "#each_filename" do
|
|
59
54
|
it "maps all its controllers and yields each in turn" do
|
|
60
55
|
stub(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -64,7 +59,6 @@ module Brainstem
|
|
|
64
59
|
end
|
|
65
60
|
end
|
|
66
61
|
|
|
67
|
-
|
|
68
62
|
describe "#formatted" do
|
|
69
63
|
it "maps all its members" do
|
|
70
64
|
mock(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -82,7 +76,6 @@ module Brainstem
|
|
|
82
76
|
end
|
|
83
77
|
end
|
|
84
78
|
|
|
85
|
-
|
|
86
79
|
describe "#formatted_with_filename" do
|
|
87
80
|
it "maps all its members and filenames" do
|
|
88
81
|
mock(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -105,7 +98,6 @@ module Brainstem
|
|
|
105
98
|
end
|
|
106
99
|
end
|
|
107
100
|
|
|
108
|
-
|
|
109
101
|
describe "#each_formatted" do
|
|
110
102
|
it "maps all its controllers and yields each in turn" do
|
|
111
103
|
mock(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -120,7 +112,6 @@ module Brainstem
|
|
|
120
112
|
end
|
|
121
113
|
end
|
|
122
114
|
|
|
123
|
-
|
|
124
115
|
describe "#each_formatted_with_filename" do
|
|
125
116
|
it "maps all its controllers and filenames and yields each in turn" do
|
|
126
117
|
mock(member).formatted_as(:markdown, {}) { "blah" }
|
|
@@ -139,7 +130,6 @@ module Brainstem
|
|
|
139
130
|
end
|
|
140
131
|
end
|
|
141
132
|
|
|
142
|
-
|
|
143
133
|
describe ".with_members" do
|
|
144
134
|
subject { described_class.with_members(atlas, member) }
|
|
145
135
|
|
|
@@ -147,7 +137,6 @@ module Brainstem
|
|
|
147
137
|
expect(subject).to be_a described_class
|
|
148
138
|
expect(subject.send(:members)).to eq [ member ]
|
|
149
139
|
end
|
|
150
|
-
|
|
151
140
|
end
|
|
152
141
|
|
|
153
142
|
it_behaves_like "atlas taker"
|
|
@@ -36,7 +36,6 @@ module Brainstem
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
describe "validation" do
|
|
41
40
|
before do
|
|
42
41
|
any_instance_of(Atlas) do |instance|
|
|
@@ -166,7 +165,6 @@ module Brainstem
|
|
|
166
165
|
end
|
|
167
166
|
end
|
|
168
167
|
|
|
169
|
-
|
|
170
168
|
context "when a route is invalid" do
|
|
171
169
|
let(:route_2) { {
|
|
172
170
|
path: "/endpoint2",
|
|
@@ -202,7 +200,6 @@ module Brainstem
|
|
|
202
200
|
end
|
|
203
201
|
end
|
|
204
202
|
|
|
205
|
-
|
|
206
203
|
describe "#extract_presenters!" do
|
|
207
204
|
let(:endpoint_1) { Object.new }
|
|
208
205
|
let(:endpoint_2) { Object.new }
|
|
@@ -249,7 +246,6 @@ module Brainstem
|
|
|
249
246
|
end
|
|
250
247
|
end
|
|
251
248
|
|
|
252
|
-
|
|
253
249
|
describe "#valid?" do
|
|
254
250
|
before do
|
|
255
251
|
any_instance_of(Atlas) do |instance|
|
|
@@ -282,7 +278,6 @@ module Brainstem
|
|
|
282
278
|
end
|
|
283
279
|
end
|
|
284
280
|
|
|
285
|
-
|
|
286
281
|
describe "#allow_route?" do
|
|
287
282
|
before do
|
|
288
283
|
any_instance_of(Atlas) do |instance|
|
|
@@ -331,7 +326,6 @@ module Brainstem
|
|
|
331
326
|
end
|
|
332
327
|
end
|
|
333
328
|
|
|
334
|
-
|
|
335
329
|
describe "#find_by_class" do
|
|
336
330
|
before do
|
|
337
331
|
any_instance_of(Atlas) do |instance|
|
|
@@ -16,7 +16,6 @@ module Brainstem
|
|
|
16
16
|
|
|
17
17
|
subject { Builder.new(default_options.merge(options)) }
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
describe "#initialize" do
|
|
21
20
|
let(:introspector_method) { Object.new }
|
|
22
21
|
let(:options) { { introspector_method: introspector_method } }
|
|
@@ -35,7 +34,6 @@ module Brainstem
|
|
|
35
34
|
end
|
|
36
35
|
end
|
|
37
36
|
|
|
38
|
-
|
|
39
37
|
describe "introspection" do
|
|
40
38
|
let(:introspector_method) { Object.new }
|
|
41
39
|
let(:args_for_introspector) { { blah: true } }
|
|
@@ -55,7 +53,6 @@ module Brainstem
|
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
|
|
58
|
-
|
|
59
56
|
it "passes the introspector method the introspector options" do
|
|
60
57
|
mock(introspector_method).call(args_for_introspector)
|
|
61
58
|
subject
|
|
@@ -67,7 +64,6 @@ module Brainstem
|
|
|
67
64
|
end
|
|
68
65
|
end
|
|
69
66
|
|
|
70
|
-
|
|
71
67
|
describe "modeling" do
|
|
72
68
|
let(:introspector) { Object.new }
|
|
73
69
|
let(:atlas_method) { Object.new }
|
|
@@ -36,7 +36,6 @@ module Brainstem
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
describe "#create_from_route" do
|
|
41
40
|
it "creates a new controller, adding it to the members" do
|
|
42
41
|
controller = subject.create_from_route(
|
|
@@ -55,7 +54,6 @@ module Brainstem
|
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
|
|
59
57
|
describe "#find_or_create_from_route" do
|
|
60
58
|
let!(:existing_controller) { subject.create_from_route(
|
|
61
59
|
path: "/posts",
|
|
@@ -15,7 +15,6 @@ module Brainstem
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
describe "#add_endpoint" do
|
|
20
19
|
let(:endpoint) { Object.new }
|
|
21
20
|
|
|
@@ -26,7 +25,6 @@ module Brainstem
|
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
|
|
30
28
|
describe "derived fields" do
|
|
31
29
|
let(:lorem) { "lorem ipsum dolor sit amet" }
|
|
32
30
|
let(:const) { Object.new }
|
|
@@ -46,7 +44,6 @@ module Brainstem
|
|
|
46
44
|
end
|
|
47
45
|
end
|
|
48
46
|
|
|
49
|
-
|
|
50
47
|
describe "configuration helpers" do
|
|
51
48
|
describe "#contextual_documentation" do
|
|
52
49
|
let(:default_config) { { title: { info: info, nodoc: nodoc } } }
|
|
@@ -93,7 +90,6 @@ module Brainstem
|
|
|
93
90
|
end
|
|
94
91
|
end
|
|
95
92
|
|
|
96
|
-
|
|
97
93
|
describe "#default_configuration" do
|
|
98
94
|
let(:default_config) { { title: nil } }
|
|
99
95
|
|
|
@@ -103,25 +99,45 @@ module Brainstem
|
|
|
103
99
|
end
|
|
104
100
|
end
|
|
105
101
|
|
|
102
|
+
describe "#tag" do
|
|
103
|
+
let(:default_config) { { tag: tag } }
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
context "when nodoc in default" do
|
|
111
|
-
let(:nodoc) { true }
|
|
105
|
+
context "when tag in specified" do
|
|
106
|
+
let(:tag) { 'Tag Name' }
|
|
112
107
|
|
|
113
108
|
it "is true" do
|
|
114
|
-
expect(subject.
|
|
109
|
+
expect(subject.tag).to eq(tag)
|
|
115
110
|
end
|
|
116
111
|
end
|
|
117
112
|
|
|
118
|
-
context "when
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
context "when tag is not specified" do
|
|
114
|
+
let(:tag) { nil }
|
|
115
|
+
|
|
116
|
+
it "is nil" do
|
|
117
|
+
expect(subject.tag).to eq(nil)
|
|
121
118
|
end
|
|
122
119
|
end
|
|
123
120
|
end
|
|
124
121
|
|
|
122
|
+
describe "#tag_groups" do
|
|
123
|
+
let(:default_config) { { tag_groups: tag_groups } }
|
|
124
|
+
|
|
125
|
+
context "when tag groups are specified" do
|
|
126
|
+
let(:tag_groups) { ['Group 1', 'Group 2'] }
|
|
127
|
+
|
|
128
|
+
it "is true" do
|
|
129
|
+
expect(subject.tag_groups).to eq(tag_groups)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
context "when tag_groups are not specified" do
|
|
134
|
+
let(:tag_groups) { nil }
|
|
135
|
+
|
|
136
|
+
it "is nil" do
|
|
137
|
+
expect(subject.tag_groups).to eq(nil)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
125
141
|
|
|
126
142
|
describe "#title" do
|
|
127
143
|
context "when present" do
|
|
@@ -149,7 +165,6 @@ module Brainstem
|
|
|
149
165
|
end
|
|
150
166
|
end
|
|
151
167
|
|
|
152
|
-
|
|
153
168
|
describe "#description" do
|
|
154
169
|
context "when present" do
|
|
155
170
|
let(:default_config) { { description: { info: lorem, nodoc: nodoc } } }
|
|
@@ -177,7 +192,6 @@ module Brainstem
|
|
|
177
192
|
end
|
|
178
193
|
end
|
|
179
194
|
|
|
180
|
-
|
|
181
195
|
describe "#suggested_filename" do
|
|
182
196
|
let(:const) { Object.new }
|
|
183
197
|
|
|
@@ -187,7 +201,6 @@ module Brainstem
|
|
|
187
201
|
end
|
|
188
202
|
end
|
|
189
203
|
|
|
190
|
-
|
|
191
204
|
it "gsubs namespace, filename and extension" do
|
|
192
205
|
instance = described_class.new(atlas,
|
|
193
206
|
filename_pattern: "controllers/{{namespace}}/{{name}}_controller.{{extension}}",
|
|
@@ -202,7 +215,6 @@ module Brainstem
|
|
|
202
215
|
end
|
|
203
216
|
end
|
|
204
217
|
|
|
205
|
-
|
|
206
218
|
describe "#suggested_filename_link" do
|
|
207
219
|
it "gsubs filename and extension" do
|
|
208
220
|
|
|
@@ -217,7 +229,6 @@ module Brainstem
|
|
|
217
229
|
end
|
|
218
230
|
end
|
|
219
231
|
|
|
220
|
-
|
|
221
232
|
it_behaves_like "formattable"
|
|
222
233
|
it_behaves_like "atlas taker"
|
|
223
234
|
end
|