praxis 2.0.pre.6 → 2.0.pre.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -3
- data/CHANGELOG.md +25 -0
- data/TODO.md +1 -4
- data/bin/praxis +67 -12
- data/lib/praxis.rb +10 -3
- data/lib/praxis/action_definition.rb +15 -13
- data/lib/praxis/action_definition/headers_dsl_compiler.rb +0 -7
- data/lib/praxis/api_general_info.rb +1 -1
- data/lib/praxis/application.rb +6 -2
- data/lib/praxis/blueprint.rb +357 -0
- data/lib/praxis/bootloader.rb +9 -3
- data/lib/praxis/bootloader_stages/environment.rb +16 -13
- data/lib/praxis/collection.rb +1 -11
- data/lib/praxis/config_hash.rb +44 -0
- data/lib/praxis/docs/{openapi → open_api}/info_object.rb +18 -10
- data/lib/praxis/docs/{openapi → open_api}/media_type_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/operation_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/parameter_object.rb +2 -2
- data/lib/praxis/docs/{openapi → open_api}/paths_object.rb +12 -15
- data/lib/praxis/docs/{openapi → open_api}/request_body_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/response_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/responses_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/schema_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/server_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/tag_object.rb +0 -0
- data/lib/praxis/docs/open_api_generator.rb +91 -6
- data/lib/praxis/endpoint_definition.rb +273 -0
- data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +57 -8
- data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +3 -16
- data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +20 -8
- data/lib/praxis/extensions/field_expansion.rb +3 -36
- data/lib/praxis/extensions/pagination.rb +5 -32
- data/lib/praxis/extensions/pagination/ordering_params.rb +5 -1
- data/lib/praxis/extensions/pagination/pagination_params.rb +10 -4
- data/lib/praxis/field_expander.rb +90 -0
- data/lib/praxis/finalizable.rb +34 -0
- data/lib/praxis/mapper/active_model_compat.rb +4 -0
- data/lib/praxis/mapper/resource.rb +18 -2
- data/lib/praxis/mapper/selector_generator.rb +2 -1
- data/lib/praxis/mapper/sequel_compat.rb +7 -0
- data/lib/praxis/media_type.rb +3 -68
- data/lib/praxis/plugin_concern.rb +1 -1
- data/lib/praxis/plugins/mapper_plugin.rb +24 -15
- data/lib/praxis/plugins/pagination_plugin.rb +34 -4
- data/lib/praxis/renderer.rb +88 -0
- data/lib/praxis/request.rb +1 -1
- data/lib/praxis/resource_definition.rb +2 -311
- data/lib/praxis/response_definition.rb +2 -10
- data/lib/praxis/response_template.rb +3 -3
- data/lib/praxis/router.rb +2 -2
- data/lib/praxis/routing_config.rb +1 -1
- data/lib/praxis/tasks/api_docs.rb +17 -64
- data/lib/praxis/tasks/routes.rb +2 -2
- data/lib/praxis/types/media_type_common.rb +1 -11
- data/lib/praxis/version.rb +1 -1
- data/praxis.gemspec +0 -1
- data/spec/functional_spec.rb +5 -9
- data/spec/praxis/action_definition_spec.rb +12 -20
- data/spec/praxis/blueprint_spec.rb +373 -0
- data/spec/praxis/bootloader_spec.rb +10 -2
- data/spec/praxis/collection_spec.rb +0 -13
- data/spec/praxis/config_hash_spec.rb +64 -0
- data/spec/praxis/{resource_definition_spec.rb → endpoint_definition_spec.rb} +37 -64
- data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +19 -8
- data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +106 -0
- data/spec/praxis/extensions/field_expansion_spec.rb +5 -24
- data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/support/spec_resources_active_model.rb +1 -1
- data/spec/praxis/field_expander_spec.rb +149 -0
- data/spec/praxis/mapper/selector_generator_spec.rb +1 -1
- data/spec/praxis/media_type_identifier_spec.rb +5 -4
- data/spec/praxis/media_type_spec.rb +4 -93
- data/spec/praxis/renderer_spec.rb +188 -0
- data/spec/praxis/response_definition_spec.rb +0 -31
- data/spec/praxis/response_spec.rb +1 -1
- data/spec/praxis/router_spec.rb +8 -8
- data/spec/praxis/routing_config_spec.rb +3 -3
- data/spec/spec_app/app/controllers/instances.rb +13 -7
- data/spec/spec_app/design/media_types/instance.rb +1 -19
- data/spec/spec_app/design/media_types/volume.rb +1 -1
- data/spec/spec_app/design/media_types/volume_snapshot.rb +2 -14
- data/spec/spec_app/design/resources/instances.rb +5 -8
- data/spec/spec_app/design/resources/volume_snapshots.rb +1 -1
- data/spec/spec_app/design/resources/volumes.rb +1 -1
- data/spec/support/spec_authorization_plugin.rb +1 -1
- data/spec/support/spec_blueprints.rb +72 -0
- data/spec/support/{spec_resource_definitions.rb → spec_endpoint_definitions.rb} +2 -2
- data/spec/support/spec_media_types.rb +6 -26
- data/tasks/thor/app.rb +8 -34
- data/tasks/thor/example.rb +51 -285
- data/tasks/thor/model.rb +40 -0
- data/tasks/thor/scaffold.rb +117 -0
- data/tasks/thor/templates/generator/empty_app/.gitignore +0 -1
- data/tasks/thor/templates/generator/empty_app/Gemfile +7 -23
- data/tasks/thor/templates/generator/empty_app/README.md +1 -1
- data/tasks/thor/templates/generator/empty_app/Rakefile +4 -13
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/config/environment.rb +26 -17
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/spec/spec_helper.rb +14 -9
- data/tasks/thor/templates/generator/example_app/.gitignore +1 -0
- data/tasks/thor/templates/generator/example_app/Gemfile +19 -0
- data/tasks/thor/templates/generator/example_app/Rakefile +61 -0
- data/tasks/thor/templates/generator/example_app/app/models/user.rb +6 -0
- data/tasks/thor/templates/generator/example_app/app/v1/concerns/controller_base.rb +24 -0
- data/tasks/thor/templates/generator/example_app/app/v1/controllers/users.rb +17 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/user.rb +25 -0
- data/tasks/thor/templates/generator/example_app/config.ru +30 -0
- data/tasks/thor/templates/generator/example_app/config/environment.rb +41 -0
- data/tasks/thor/templates/generator/example_app/db/migrate/20201010101010_create_users_table.rb +12 -0
- data/tasks/thor/templates/generator/example_app/db/seeds.rb +6 -0
- data/tasks/thor/templates/generator/example_app/design/api.rb +18 -0
- data/tasks/thor/templates/generator/example_app/design/v1/endpoints/users.rb +37 -0
- data/tasks/thor/templates/generator/example_app/design/v1/media_types/user.rb +21 -0
- data/tasks/thor/templates/generator/example_app/spec/helpers/database_helper.rb +20 -0
- data/tasks/thor/templates/generator/example_app/spec/spec_helper.rb +42 -0
- data/tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb +37 -0
- data/tasks/thor/templates/generator/scaffold/design/endpoints/collection.rb +98 -0
- data/tasks/thor/templates/generator/scaffold/design/media_types/item.rb +18 -0
- data/tasks/thor/templates/generator/scaffold/implementation/controllers/collection.rb +77 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/item.rb +45 -0
- data/tasks/thor/templates/generator/scaffold/models/active_record.rb +6 -0
- data/tasks/thor/templates/generator/scaffold/models/sequel.rb +6 -0
- metadata +62 -136
- data/lib/api_browser/.bowerrc +0 -3
- data/lib/api_browser/.editorconfig +0 -21
- data/lib/api_browser/Gruntfile.js +0 -581
- data/lib/api_browser/app/index.html +0 -59
- data/lib/api_browser/app/js/app.js +0 -48
- data/lib/api_browser/app/js/controllers/action.js +0 -47
- data/lib/api_browser/app/js/controllers/controller.js +0 -10
- data/lib/api_browser/app/js/controllers/menu.js +0 -93
- data/lib/api_browser/app/js/controllers/trait.js +0 -10
- data/lib/api_browser/app/js/controllers/type.js +0 -24
- data/lib/api_browser/app/js/directives/attribute_description.js +0 -56
- data/lib/api_browser/app/js/directives/attribute_table.js +0 -28
- data/lib/api_browser/app/js/directives/conditional_requirements.js +0 -13
- data/lib/api_browser/app/js/directives/fixed_if_fits.js +0 -38
- data/lib/api_browser/app/js/directives/highlight.js +0 -14
- data/lib/api_browser/app/js/directives/menu_item.js +0 -59
- data/lib/api_browser/app/js/directives/no_container.js +0 -8
- data/lib/api_browser/app/js/directives/readable_list.js +0 -87
- data/lib/api_browser/app/js/directives/request_examples.js +0 -31
- data/lib/api_browser/app/js/directives/type_placeholder.js +0 -30
- data/lib/api_browser/app/js/directives/url.js +0 -15
- data/lib/api_browser/app/js/factories/Configuration.js +0 -12
- data/lib/api_browser/app/js/factories/Documentation.js +0 -61
- data/lib/api_browser/app/js/factories/Example.js +0 -51
- data/lib/api_browser/app/js/factories/PageInfo.js +0 -9
- data/lib/api_browser/app/js/factories/normalize_attributes.js +0 -20
- data/lib/api_browser/app/js/factories/prepare_template.js +0 -15
- data/lib/api_browser/app/js/factories/template_for.js +0 -128
- data/lib/api_browser/app/js/filters/attribute_name.js +0 -10
- data/lib/api_browser/app/js/filters/friendly_json.js +0 -5
- data/lib/api_browser/app/js/filters/has_requirement.js +0 -14
- data/lib/api_browser/app/js/filters/header_info.js +0 -9
- data/lib/api_browser/app/js/filters/is_empty.js +0 -8
- data/lib/api_browser/app/js/filters/markdown.js +0 -6
- data/lib/api_browser/app/js/filters/resource_name.js +0 -5
- data/lib/api_browser/app/js/filters/tag_requirement.js +0 -13
- data/lib/api_browser/app/sass/modules/_body.scss +0 -40
- data/lib/api_browser/app/sass/modules/_cloke.scss +0 -8
- data/lib/api_browser/app/sass/modules/_header.scss +0 -10
- data/lib/api_browser/app/sass/modules/_nav.scss +0 -7
- data/lib/api_browser/app/sass/modules/_sidebar.scss +0 -134
- data/lib/api_browser/app/sass/modules/_switch.scss +0 -55
- data/lib/api_browser/app/sass/modules/_table.scss +0 -13
- data/lib/api_browser/app/sass/praxis.scss +0 -70
- data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +0 -774
- data/lib/api_browser/app/views/action.html +0 -97
- data/lib/api_browser/app/views/builtin/field-selector.html +0 -24
- data/lib/api_browser/app/views/controller.html +0 -55
- data/lib/api_browser/app/views/directives/attribute_description.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/default.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/example.html +0 -13
- data/lib/api_browser/app/views/directives/attribute_description/headers.html +0 -8
- data/lib/api_browser/app/views/directives/attribute_description/member_options.html +0 -4
- data/lib/api_browser/app/views/directives/attribute_description/values.html +0 -14
- data/lib/api_browser/app/views/directives/attribute_table.html +0 -17
- data/lib/api_browser/app/views/directives/menu_item.html +0 -8
- data/lib/api_browser/app/views/directives/url.html +0 -3
- data/lib/api_browser/app/views/examples/general.html +0 -26
- data/lib/api_browser/app/views/home.html +0 -5
- data/lib/api_browser/app/views/layout.html +0 -8
- data/lib/api_browser/app/views/menu.html +0 -42
- data/lib/api_browser/app/views/navbar.html +0 -9
- data/lib/api_browser/app/views/trait.html +0 -13
- data/lib/api_browser/app/views/type.html +0 -6
- data/lib/api_browser/app/views/type/details.html +0 -33
- data/lib/api_browser/app/views/types/embedded/array.html +0 -2
- data/lib/api_browser/app/views/types/embedded/default.html +0 -12
- data/lib/api_browser/app/views/types/embedded/field-selector.html +0 -13
- data/lib/api_browser/app/views/types/embedded/links.html +0 -11
- data/lib/api_browser/app/views/types/embedded/requirements.html +0 -6
- data/lib/api_browser/app/views/types/embedded/single_req.html +0 -9
- data/lib/api_browser/app/views/types/embedded/struct.html +0 -14
- data/lib/api_browser/app/views/types/label/link.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive_collection.html +0 -1
- data/lib/api_browser/app/views/types/label/type.html +0 -1
- data/lib/api_browser/app/views/types/label/type_collection.html +0 -1
- data/lib/api_browser/app/views/types/main/array.html +0 -22
- data/lib/api_browser/app/views/types/main/default.html +0 -23
- data/lib/api_browser/app/views/types/main/hash.html +0 -23
- data/lib/api_browser/app/views/types/standalone/array.html +0 -3
- data/lib/api_browser/app/views/types/standalone/default.html +0 -18
- data/lib/api_browser/app/views/types/standalone/struct.html +0 -2
- data/lib/api_browser/bower_template.json +0 -41
- data/lib/api_browser/package-lock.json +0 -7110
- data/lib/api_browser/package.json +0 -43
- data/lib/praxis/docs/generator.rb +0 -243
- data/lib/praxis/docs/link_builder.rb +0 -30
- data/lib/praxis/links.rb +0 -135
- data/lib/praxis/types/multipart.rb +0 -109
- data/spec/api_browser/directives/type_placeholder_spec.js +0 -134
- data/spec/api_browser/factories/configuration_spec.js +0 -32
- data/spec/api_browser/factories/documentation_spec.js +0 -100
- data/spec/api_browser/factories/normalize_attributes_spec.js +0 -92
- data/spec/api_browser/factories/template_for_spec.js +0 -67
- data/spec/api_browser/filters/attribute_name_spec.js +0 -23
- data/spec/praxis/types/multipart_spec.rb +0 -112
- data/tasks/thor/templates/generator/empty_app/.rspec +0 -1
- data/tasks/thor/templates/generator/empty_app/Guardfile +0 -3
- data/tasks/thor/templates/generator/empty_app/config/rainbows.rb +0 -57
- data/tasks/thor/templates/generator/empty_app/docs/app.js +0 -1
- data/tasks/thor/templates/generator/empty_app/docs/styles.scss +0 -3
@@ -1,109 +0,0 @@
|
|
1
|
-
module Praxis
|
2
|
-
class Multipart < Attributor::Hash
|
3
|
-
|
4
|
-
@key_type = Attributor::String
|
5
|
-
|
6
|
-
def self.inherited(klass)
|
7
|
-
warn "DEPRECATION: Praxis::Multipart is deprecated and will be removed in 1.0. Use Praxis::Types::MultipartArray instead"
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.load(value, context=Attributor::DEFAULT_ROOT_CONTEXT, content_type:nil)
|
12
|
-
return value if value.kind_of?(self) || value.nil?
|
13
|
-
|
14
|
-
unless (value.kind_of?(::String) && ! content_type.nil?)
|
15
|
-
raise Attributor::CoercionError.new(context: context, from: value.class, to: self.name, value: value)
|
16
|
-
end
|
17
|
-
|
18
|
-
headers = {'Content-Type' => content_type}
|
19
|
-
parser = MultipartParser.new(headers, value)
|
20
|
-
preamble, parts = parser.parse
|
21
|
-
|
22
|
-
parts_hash = parts.each_with_object({}) do |part, hash|
|
23
|
-
hash[part.name] = self.backconvert_part_data(part)
|
24
|
-
end
|
25
|
-
|
26
|
-
hash = Hash[parts_hash.collect { |name, part| [name, part.body] }]
|
27
|
-
|
28
|
-
instance = super(hash, context, **options)
|
29
|
-
|
30
|
-
instance.preamble = preamble
|
31
|
-
instance.parts = parts_hash
|
32
|
-
instance.headers = headers
|
33
|
-
|
34
|
-
instance
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.backconvert_part_data(part)
|
38
|
-
filename = part.filename
|
39
|
-
body = part.payload
|
40
|
-
name = part.name
|
41
|
-
|
42
|
-
content_type = part.headers['Content-Type']
|
43
|
-
|
44
|
-
# cheat and unparse the headers back to a head string. should be ok...
|
45
|
-
head = part.headers.collect {|k,v| "#{k}: #{v}" }.join("\r\n")
|
46
|
-
|
47
|
-
data = nil
|
48
|
-
if filename == ""
|
49
|
-
# filename is blank which means no file has been selected
|
50
|
-
return data
|
51
|
-
elsif filename
|
52
|
-
body.rewind
|
53
|
-
|
54
|
-
data = {:filename => filename, :type => content_type,
|
55
|
-
:name => name, :tempfile => body, :head => head}
|
56
|
-
elsif !filename && content_type && body.is_a?(IO)
|
57
|
-
body.rewind
|
58
|
-
|
59
|
-
# Generic multipart cases, not coming from a form
|
60
|
-
data = {:type => content_type,
|
61
|
-
:name => name, :tempfile => body, :head => head}
|
62
|
-
else
|
63
|
-
data = body
|
64
|
-
end
|
65
|
-
|
66
|
-
part.payload = data
|
67
|
-
part
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def self.example(context=nil, options: {})
|
72
|
-
form = MIME::Multipart::FormData.new
|
73
|
-
|
74
|
-
super(context, options: options).each do |k,v|
|
75
|
-
body = if v.respond_to?(:dump) && !v.kind_of?(String)
|
76
|
-
JSON.pretty_generate(v.dump)
|
77
|
-
else
|
78
|
-
v
|
79
|
-
end
|
80
|
-
|
81
|
-
entity = MIME::Text.new(body)
|
82
|
-
|
83
|
-
form.add entity, String(k)
|
84
|
-
end
|
85
|
-
|
86
|
-
content_type = form.headers.get('Content-Type')
|
87
|
-
body = form.body.to_s
|
88
|
-
|
89
|
-
self.load(body, context, content_type: content_type)
|
90
|
-
end
|
91
|
-
|
92
|
-
attr_accessor :preamble
|
93
|
-
attr_accessor :parts
|
94
|
-
attr_accessor :headers
|
95
|
-
|
96
|
-
|
97
|
-
def validate(context=Attributor::DEFAULT_ROOT_CONTEXT)
|
98
|
-
super
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.describe(shallow = false, **opts)
|
102
|
-
hash = super(**opts)
|
103
|
-
hash.merge!(family: 'multipart')
|
104
|
-
hash
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
describe('typePlaceholder', function() {
|
2
|
-
describe('basic operation', function() {
|
3
|
-
var $scope, element, spy, fakeTemplate;
|
4
|
-
beforeEach(angular.mock.module('PraxisDocBrowser', function($provide) {
|
5
|
-
spy = jasmine.createSpy('templateFor').and.callFake(function() {
|
6
|
-
return fakeTemplate();
|
7
|
-
});
|
8
|
-
$provide.value('templateFor', spy);
|
9
|
-
}));
|
10
|
-
|
11
|
-
beforeEach(inject(function($compile, $rootScope, $q) {
|
12
|
-
fakeTemplate = function() {
|
13
|
-
return $q.when($compile('<div>result = <span>{{type.name}}</div>'));
|
14
|
-
};
|
15
|
-
$scope = $rootScope.$new();
|
16
|
-
$scope.type = {name: 'test'};
|
17
|
-
element = $compile('<div><type-placeholder type=type template=embedded></type-placeholder></div>')($scope);
|
18
|
-
$scope.$apply();
|
19
|
-
}));
|
20
|
-
|
21
|
-
it('calls template for', function() {
|
22
|
-
expect(spy).toHaveBeenCalledWith($scope.type, 'embedded');
|
23
|
-
});
|
24
|
-
|
25
|
-
it('replaces itself', function() {
|
26
|
-
expect(element.text()).toEqual('result = test');
|
27
|
-
});
|
28
|
-
});
|
29
|
-
|
30
|
-
describe('actual rendering', function() {
|
31
|
-
var $scope, element;
|
32
|
-
|
33
|
-
function rowLooksLike(n, vals) {
|
34
|
-
return function() {
|
35
|
-
var row = element.find('table tr').eq(n).children();
|
36
|
-
_.each(vals, function(val, i) {
|
37
|
-
if (_.isString(val)) {
|
38
|
-
expect(row.eq(i).text()).toEqual(val);
|
39
|
-
} else {
|
40
|
-
expect(row.eq(i).text()).toMatch(val);
|
41
|
-
}
|
42
|
-
});
|
43
|
-
expect(row.length).toBe(vals.length);
|
44
|
-
};
|
45
|
-
}
|
46
|
-
|
47
|
-
beforeEach(angular.mock.module('PraxisDocBrowser'));
|
48
|
-
|
49
|
-
describe('standalone', function() {
|
50
|
-
beforeEach(inject(function($compile, $rootScope) {
|
51
|
-
$scope = $rootScope.$new();
|
52
|
-
$scope.type = { // TODO figure out how to exercise the entire app
|
53
|
-
name: 'Struct',
|
54
|
-
family: 'hash',
|
55
|
-
attributes: {
|
56
|
-
view: {
|
57
|
-
options: {
|
58
|
-
default: 'default',
|
59
|
-
example: '"default"'
|
60
|
-
},
|
61
|
-
type: {
|
62
|
-
name: 'String'
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
element = $compile('<div><type-placeholder type="type" template="standalone" details="type.attributes"></type-placeholder></div>')($scope);
|
68
|
-
$scope.$apply();
|
69
|
-
}));
|
70
|
-
|
71
|
-
it('renders out a table', function() {
|
72
|
-
expect(element.find('table').length).toBe(1);
|
73
|
-
});
|
74
|
-
|
75
|
-
it('displays table headings', rowLooksLike(0,
|
76
|
-
['Attribute', 'Type', 'Description']
|
77
|
-
));
|
78
|
-
|
79
|
-
it('displays an optional heading', rowLooksLike(1,
|
80
|
-
['Optional']
|
81
|
-
));
|
82
|
-
|
83
|
-
it('has a table row for the attribute', rowLooksLike(2,
|
84
|
-
['view', 'String', /default.*default.*example.*"default"/mi]
|
85
|
-
));
|
86
|
-
});
|
87
|
-
|
88
|
-
describe('embedded', function() {
|
89
|
-
var compile;
|
90
|
-
beforeEach(inject(function($compile, $rootScope) {
|
91
|
-
$scope = $rootScope.$new();
|
92
|
-
compile = $compile('<div><table><tr type-placeholder type="item.type" template="embedded" details="item" name="item.name"></tr></table></div>');
|
93
|
-
}));
|
94
|
-
|
95
|
-
describe('struct', function() {
|
96
|
-
beforeEach(function() {
|
97
|
-
$scope.item = { // TODO figure out how to exercise the entire app
|
98
|
-
type: {
|
99
|
-
name: 'Struct',
|
100
|
-
family: 'hash',
|
101
|
-
attributes: {
|
102
|
-
view: {
|
103
|
-
options: {
|
104
|
-
default: 'default',
|
105
|
-
example: '"default"'
|
106
|
-
},
|
107
|
-
type: {
|
108
|
-
name: 'String'
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
},
|
113
|
-
name: 'Test1',
|
114
|
-
description: 'Heading'
|
115
|
-
};
|
116
|
-
element = compile($scope);
|
117
|
-
$scope.$apply();
|
118
|
-
});
|
119
|
-
|
120
|
-
it('renders out a table', function() {
|
121
|
-
expect(element.find('table').length).toBe(1);
|
122
|
-
});
|
123
|
-
|
124
|
-
it('displays a row fow the type', rowLooksLike(0,
|
125
|
-
['Test1', 'Struct', /Heading/]
|
126
|
-
));
|
127
|
-
|
128
|
-
it('displays a row for the subattribute', rowLooksLike(1,
|
129
|
-
['Test1.view', 'String', /default.*default.*example.*"default"/mi]
|
130
|
-
));
|
131
|
-
});
|
132
|
-
});
|
133
|
-
});
|
134
|
-
});
|
@@ -1,32 +0,0 @@
|
|
1
|
-
describe('Configuration', function() {
|
2
|
-
var theConfigProvider, runFn;
|
3
|
-
beforeEach(function() {
|
4
|
-
angular.module('PraxisDocBrowser').config(function(ConfigurationProvider) {
|
5
|
-
theConfigProvider = ConfigurationProvider;
|
6
|
-
});
|
7
|
-
runFn = angular.module('PraxisDocBrowser')._runBlocks[0];
|
8
|
-
});
|
9
|
-
|
10
|
-
beforeEach(angular.mock.module('PraxisDocBrowser'));
|
11
|
-
|
12
|
-
beforeEach(inject(function(Configuration) {
|
13
|
-
Configuration;
|
14
|
-
}));
|
15
|
-
|
16
|
-
it('sets sensible defaults', function() {
|
17
|
-
expect(theConfigProvider).toEqual(jasmine.objectContaining({
|
18
|
-
title: 'API Browser',
|
19
|
-
versionLabel: 'API Version',
|
20
|
-
expandChildren: true
|
21
|
-
}));
|
22
|
-
});
|
23
|
-
|
24
|
-
it('assigns all things from the provider unto the root scope', inject(function($injector, $rootScope) {
|
25
|
-
$injector.invoke(runFn);
|
26
|
-
expect($rootScope).toEqual(jasmine.objectContaining({
|
27
|
-
title: 'API Browser',
|
28
|
-
versionLabel: 'API Version',
|
29
|
-
expandChildren: true
|
30
|
-
}));
|
31
|
-
}));
|
32
|
-
});
|
@@ -1,100 +0,0 @@
|
|
1
|
-
describe('Documentation service', function() {
|
2
|
-
var $scope, Documentation, $httpBackend;
|
3
|
-
|
4
|
-
beforeEach(angular.mock.module('PraxisDocBrowser'));
|
5
|
-
|
6
|
-
beforeEach(inject(function($rootScope, $injector) {
|
7
|
-
$httpBackend = $injector.get('$httpBackend');
|
8
|
-
$httpBackend.expectGET('api/index-new.json').respond({
|
9
|
-
versions: ['1.0', '2.0']
|
10
|
-
});
|
11
|
-
$httpBackend.expectGET('api/1.0.json').respond({
|
12
|
-
resources: {
|
13
|
-
foo: {
|
14
|
-
|
15
|
-
}
|
16
|
-
},
|
17
|
-
schemas: {
|
18
|
-
bar: {
|
19
|
-
|
20
|
-
}
|
21
|
-
}
|
22
|
-
});
|
23
|
-
$httpBackend.expectGET('api/2.0.json').respond({
|
24
|
-
resources: {
|
25
|
-
test: 'TestCTRL'
|
26
|
-
},
|
27
|
-
schemas: {
|
28
|
-
testType: 'TestType'
|
29
|
-
}
|
30
|
-
});
|
31
|
-
$scope = $rootScope.$new();
|
32
|
-
Documentation = $injector.get('Documentation');
|
33
|
-
$httpBackend.flush();
|
34
|
-
}));
|
35
|
-
|
36
|
-
afterEach(function() {
|
37
|
-
$httpBackend.verifyNoOutstandingExpectation();
|
38
|
-
$httpBackend.verifyNoOutstandingRequest();
|
39
|
-
});
|
40
|
-
|
41
|
-
describe('#versions', function() {
|
42
|
-
var versions;
|
43
|
-
beforeEach(function() {
|
44
|
-
Documentation.versions().then(function(v) {
|
45
|
-
versions = v;
|
46
|
-
});
|
47
|
-
$scope.$apply();
|
48
|
-
});
|
49
|
-
it('returns both versions', function() {
|
50
|
-
expect(versions).toEqual(['1.0', '2.0']);
|
51
|
-
});
|
52
|
-
});
|
53
|
-
|
54
|
-
describe('#items', function() {
|
55
|
-
var items;
|
56
|
-
beforeEach(function() {
|
57
|
-
Documentation.items('1.0').then(function(data) {
|
58
|
-
items = data;
|
59
|
-
});
|
60
|
-
$scope.$apply();
|
61
|
-
});
|
62
|
-
|
63
|
-
it('returns all items for 1.0', function() {
|
64
|
-
expect(items).toEqual({
|
65
|
-
resources: {
|
66
|
-
foo: { }
|
67
|
-
},
|
68
|
-
schemas: {
|
69
|
-
bar: {}
|
70
|
-
}
|
71
|
-
});
|
72
|
-
});
|
73
|
-
});
|
74
|
-
describe('#controller', function() {
|
75
|
-
var item;
|
76
|
-
beforeEach(function() {
|
77
|
-
Documentation.controller('2.0', 'test').then(function(data) {
|
78
|
-
item = data;
|
79
|
-
});
|
80
|
-
$scope.$apply();
|
81
|
-
});
|
82
|
-
|
83
|
-
it('returns all items for 1.0', function() {
|
84
|
-
expect(item).toEqual('TestCTRL');
|
85
|
-
});
|
86
|
-
});
|
87
|
-
describe('#type', function() {
|
88
|
-
var item;
|
89
|
-
beforeEach(function() {
|
90
|
-
Documentation.type('2.0', 'testType').then(function(data) {
|
91
|
-
item = data;
|
92
|
-
});
|
93
|
-
$scope.$apply();
|
94
|
-
});
|
95
|
-
|
96
|
-
it('returns all items for 1.0', function() {
|
97
|
-
expect(item).toEqual('TestType');
|
98
|
-
});
|
99
|
-
});
|
100
|
-
});
|
@@ -1,92 +0,0 @@
|
|
1
|
-
describe('normalizeAttributes', function() {
|
2
|
-
var normalizeAttributes;
|
3
|
-
beforeEach(angular.mock.module('PraxisDocBrowser'));
|
4
|
-
|
5
|
-
beforeEach(inject(function($rootScope, $injector) {
|
6
|
-
normalizeAttributes = $injector.get('normalizeAttributes');
|
7
|
-
}));
|
8
|
-
|
9
|
-
var type = {
|
10
|
-
attributes: {
|
11
|
-
test1: {
|
12
|
-
values: ['Hello'],
|
13
|
-
irrelevantFlag: true
|
14
|
-
},
|
15
|
-
test2: {
|
16
|
-
type: {
|
17
|
-
attributes: {
|
18
|
-
test3: {
|
19
|
-
default: 'Yeah'
|
20
|
-
},
|
21
|
-
moreRecursive: {
|
22
|
-
type: {
|
23
|
-
attributes: {
|
24
|
-
test4: {}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
},
|
32
|
-
example: {
|
33
|
-
test1: 'Hello',
|
34
|
-
test2: {
|
35
|
-
test3: 'Yeah',
|
36
|
-
moreRecursive: {
|
37
|
-
test4: 3
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
var expected = {
|
44
|
-
test1: {
|
45
|
-
options: {
|
46
|
-
values: ['Hello'],
|
47
|
-
}
|
48
|
-
},
|
49
|
-
test2: {
|
50
|
-
options: {
|
51
|
-
},
|
52
|
-
type: {
|
53
|
-
attributes: {
|
54
|
-
test3: {
|
55
|
-
options: {
|
56
|
-
default: 'Yeah',
|
57
|
-
}
|
58
|
-
},
|
59
|
-
moreRecursive: {
|
60
|
-
options: {
|
61
|
-
},
|
62
|
-
type: {
|
63
|
-
attributes: {
|
64
|
-
test4: {
|
65
|
-
options: {
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
};
|
75
|
-
|
76
|
-
expected = (function wrap(obj) { // this will wrap each object in objectContaining
|
77
|
-
if (_.isObject(obj)) {
|
78
|
-
return jasmine.objectContaining(_.mapValues(obj, wrap));
|
79
|
-
}
|
80
|
-
return obj;
|
81
|
-
})(expected);
|
82
|
-
|
83
|
-
|
84
|
-
it('normalizes attributes into options recursively', function() {
|
85
|
-
normalizeAttributes(type, type.attributes);
|
86
|
-
expect(type.attributes).toEqual(expected);
|
87
|
-
});
|
88
|
-
|
89
|
-
it('doesn\'t include irrelevant options', function() {
|
90
|
-
expect(type.attributes.test1.options.irrelevantFlag).toBeUndefined();
|
91
|
-
});
|
92
|
-
});
|