active_model_serializers 0.8.3 → 0.10.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +29 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +105 -0
- data/.simplecov +110 -0
- data/.travis.yml +50 -24
- data/CHANGELOG.md +650 -6
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +105 -0
- data/Gemfile +69 -1
- data/{MIT-LICENSE.txt → MIT-LICENSE} +3 -2
- data/README.md +195 -545
- data/Rakefile +64 -8
- data/active_model_serializers.gemspec +62 -23
- data/appveyor.yml +28 -0
- data/bin/bench +171 -0
- data/bin/bench_regression +316 -0
- data/bin/rubocop +38 -0
- data/bin/serve_benchmark +39 -0
- data/docs/README.md +41 -0
- data/docs/STYLE.md +58 -0
- data/docs/general/adapters.md +269 -0
- data/docs/general/caching.md +58 -0
- data/docs/general/configuration_options.md +185 -0
- data/docs/general/deserialization.md +100 -0
- data/docs/general/fields.md +31 -0
- data/docs/general/getting_started.md +133 -0
- data/docs/general/instrumentation.md +40 -0
- data/docs/general/key_transforms.md +40 -0
- data/docs/general/logging.md +21 -0
- data/docs/general/rendering.md +293 -0
- data/docs/general/serializers.md +495 -0
- data/docs/how-open-source-maintained.jpg +0 -0
- data/docs/howto/add_pagination_links.md +138 -0
- data/docs/howto/add_relationship_links.md +140 -0
- data/docs/howto/add_root_key.md +62 -0
- data/docs/howto/grape_integration.md +42 -0
- data/docs/howto/outside_controller_use.md +66 -0
- data/docs/howto/passing_arbitrary_options.md +27 -0
- data/docs/howto/serialize_poro.md +73 -0
- data/docs/howto/test.md +154 -0
- data/docs/howto/upgrade_from_0_8_to_0_10.md +265 -0
- data/docs/integrations/ember-and-json-api.md +147 -0
- data/docs/integrations/grape.md +19 -0
- data/docs/jsonapi/errors.md +56 -0
- data/docs/jsonapi/schema/schema.json +366 -0
- data/docs/jsonapi/schema.md +151 -0
- data/docs/rfcs/0000-namespace.md +106 -0
- data/docs/rfcs/template.md +15 -0
- data/lib/action_controller/serialization.rb +43 -38
- data/lib/active_model/serializable_resource.rb +11 -0
- data/lib/active_model/serializer/adapter/attributes.rb +15 -0
- data/lib/active_model/serializer/adapter/base.rb +18 -0
- data/lib/active_model/serializer/adapter/json.rb +15 -0
- data/lib/active_model/serializer/adapter/json_api.rb +15 -0
- data/lib/active_model/serializer/adapter/null.rb +15 -0
- data/lib/active_model/serializer/adapter.rb +24 -0
- data/lib/active_model/serializer/array_serializer.rb +12 -0
- data/lib/active_model/serializer/association.rb +71 -0
- data/lib/active_model/serializer/attribute.rb +25 -0
- data/lib/active_model/serializer/belongs_to_reflection.rb +11 -0
- data/lib/active_model/serializer/collection_serializer.rb +88 -0
- data/lib/active_model/serializer/concerns/caching.rb +300 -0
- data/lib/active_model/serializer/error_serializer.rb +14 -0
- data/lib/active_model/serializer/errors_serializer.rb +32 -0
- data/lib/active_model/serializer/field.rb +90 -0
- data/lib/active_model/serializer/fieldset.rb +31 -0
- data/lib/active_model/serializer/has_many_reflection.rb +10 -0
- data/lib/active_model/serializer/has_one_reflection.rb +7 -0
- data/lib/active_model/serializer/lazy_association.rb +96 -0
- data/lib/active_model/serializer/link.rb +21 -0
- data/lib/active_model/serializer/lint.rb +150 -0
- data/lib/active_model/serializer/null.rb +17 -0
- data/lib/active_model/serializer/reflection.rb +210 -0
- data/lib/active_model/{serializers → serializer}/version.rb +1 -1
- data/lib/active_model/serializer.rb +343 -442
- data/lib/active_model_serializers/adapter/attributes.rb +13 -0
- data/lib/active_model_serializers/adapter/base.rb +83 -0
- data/lib/active_model_serializers/adapter/json.rb +21 -0
- data/lib/active_model_serializers/adapter/json_api/deserialization.rb +213 -0
- data/lib/active_model_serializers/adapter/json_api/error.rb +96 -0
- data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +49 -0
- data/lib/active_model_serializers/adapter/json_api/link.rb +83 -0
- data/lib/active_model_serializers/adapter/json_api/meta.rb +37 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +88 -0
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +104 -0
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +66 -0
- data/lib/active_model_serializers/adapter/json_api.rb +533 -0
- data/lib/active_model_serializers/adapter/null.rb +9 -0
- data/lib/active_model_serializers/adapter.rb +98 -0
- data/lib/active_model_serializers/callbacks.rb +55 -0
- data/lib/active_model_serializers/deprecate.rb +54 -0
- data/lib/active_model_serializers/deserialization.rb +15 -0
- data/lib/active_model_serializers/json_pointer.rb +14 -0
- data/lib/active_model_serializers/logging.rb +122 -0
- data/lib/active_model_serializers/lookup_chain.rb +80 -0
- data/lib/active_model_serializers/model.rb +130 -0
- data/lib/active_model_serializers/railtie.rb +50 -0
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +78 -0
- data/lib/active_model_serializers/serializable_resource.rb +82 -0
- data/lib/active_model_serializers/serialization_context.rb +39 -0
- data/lib/active_model_serializers/test/schema.rb +138 -0
- data/lib/active_model_serializers/test/serializer.rb +125 -0
- data/lib/active_model_serializers/test.rb +7 -0
- data/lib/active_model_serializers.rb +47 -81
- data/lib/generators/rails/USAGE +6 -0
- data/lib/generators/rails/resource_override.rb +10 -0
- data/lib/generators/rails/serializer_generator.rb +36 -0
- data/lib/generators/rails/templates/serializer.rb.erb +8 -0
- data/lib/grape/active_model_serializers.rb +16 -0
- data/lib/grape/formatters/active_model_serializers.rb +32 -0
- data/lib/grape/helpers/active_model_serializers.rb +17 -0
- data/lib/tasks/rubocop.rake +53 -0
- data/test/action_controller/adapter_selector_test.rb +62 -0
- data/test/action_controller/explicit_serializer_test.rb +135 -0
- data/test/action_controller/json/include_test.rb +246 -0
- data/test/action_controller/json_api/deserialization_test.rb +112 -0
- data/test/action_controller/json_api/errors_test.rb +40 -0
- data/test/action_controller/json_api/fields_test.rb +66 -0
- data/test/action_controller/json_api/linked_test.rb +202 -0
- data/test/action_controller/json_api/pagination_test.rb +124 -0
- data/test/action_controller/json_api/transform_test.rb +189 -0
- data/test/action_controller/lookup_proc_test.rb +49 -0
- data/test/action_controller/namespace_lookup_test.rb +232 -0
- data/test/action_controller/serialization_scope_name_test.rb +235 -0
- data/test/action_controller/serialization_test.rb +478 -0
- data/test/active_model_serializers/adapter_for_test.rb +208 -0
- data/test/active_model_serializers/json_pointer_test.rb +22 -0
- data/test/active_model_serializers/logging_test.rb +77 -0
- data/test/active_model_serializers/model_test.rb +142 -0
- data/test/active_model_serializers/railtie_test_isolated.rb +68 -0
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +161 -0
- data/test/active_model_serializers/serialization_context_test_isolated.rb +71 -0
- data/test/active_model_serializers/test/schema_test.rb +131 -0
- data/test/active_model_serializers/test/serializer_test.rb +62 -0
- data/test/active_record_test.rb +9 -0
- data/test/adapter/attributes_test.rb +40 -0
- data/test/adapter/deprecation_test.rb +100 -0
- data/test/adapter/json/belongs_to_test.rb +45 -0
- data/test/adapter/json/collection_test.rb +104 -0
- data/test/adapter/json/has_many_test.rb +53 -0
- data/test/adapter/json/transform_test.rb +93 -0
- data/test/adapter/json_api/belongs_to_test.rb +155 -0
- data/test/adapter/json_api/collection_test.rb +96 -0
- data/test/adapter/json_api/errors_test.rb +76 -0
- data/test/adapter/json_api/fields_test.rb +96 -0
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +96 -0
- data/test/adapter/json_api/has_many_test.rb +173 -0
- data/test/adapter/json_api/has_one_test.rb +80 -0
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +213 -0
- data/test/adapter/json_api/json_api_test.rb +33 -0
- data/test/adapter/json_api/linked_test.rb +413 -0
- data/test/adapter/json_api/links_test.rb +110 -0
- data/test/adapter/json_api/pagination_links_test.rb +206 -0
- data/test/adapter/json_api/parse_test.rb +137 -0
- data/test/adapter/json_api/relationship_test.rb +397 -0
- data/test/adapter/json_api/resource_meta_test.rb +100 -0
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +82 -0
- data/test/adapter/json_api/transform_test.rb +512 -0
- data/test/adapter/json_api/type_test.rb +193 -0
- data/test/adapter/json_test.rb +46 -0
- data/test/adapter/null_test.rb +22 -0
- data/test/adapter/polymorphic_test.rb +218 -0
- data/test/adapter_test.rb +67 -0
- data/test/array_serializer_test.rb +20 -73
- data/test/benchmark/app.rb +65 -0
- data/test/benchmark/benchmarking_support.rb +67 -0
- data/test/benchmark/bm_active_record.rb +81 -0
- data/test/benchmark/bm_adapter.rb +38 -0
- data/test/benchmark/bm_caching.rb +119 -0
- data/test/benchmark/bm_lookup_chain.rb +83 -0
- data/test/benchmark/bm_transform.rb +45 -0
- data/test/benchmark/config.ru +3 -0
- data/test/benchmark/controllers.rb +83 -0
- data/test/benchmark/fixtures.rb +219 -0
- data/test/cache_test.rb +651 -0
- data/test/collection_serializer_test.rb +127 -0
- data/test/fixtures/active_record.rb +113 -0
- data/test/fixtures/poro.rb +225 -0
- data/test/generators/scaffold_controller_generator_test.rb +24 -0
- data/test/generators/serializer_generator_test.rb +75 -0
- data/test/grape_test.rb +196 -0
- data/test/lint_test.rb +49 -0
- data/test/logger_test.rb +20 -0
- data/test/poro_test.rb +9 -0
- data/test/serializable_resource_test.rb +79 -0
- data/test/serializers/association_macros_test.rb +37 -0
- data/test/serializers/associations_test.rb +518 -0
- data/test/serializers/attribute_test.rb +153 -0
- data/test/serializers/attributes_test.rb +52 -0
- data/test/serializers/caching_configuration_test_isolated.rb +170 -0
- data/test/serializers/configuration_test.rb +32 -0
- data/test/serializers/fieldset_test.rb +14 -0
- data/test/serializers/meta_test.rb +202 -0
- data/test/serializers/options_test.rb +32 -0
- data/test/serializers/read_attribute_for_serialization_test.rb +79 -0
- data/test/serializers/reflection_test.rb +479 -0
- data/test/serializers/root_test.rb +21 -0
- data/test/serializers/serialization_test.rb +55 -0
- data/test/serializers/serializer_for_test.rb +136 -0
- data/test/serializers/serializer_for_with_namespace_test.rb +88 -0
- data/test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json +6 -0
- data/test/support/isolated_unit.rb +84 -0
- data/test/support/rails5_shims.rb +53 -0
- data/test/support/rails_app.rb +38 -0
- data/test/support/schemas/active_model_serializers/test/schema_test/my/index.json +6 -0
- data/test/support/schemas/active_model_serializers/test/schema_test/my/show.json +6 -0
- data/test/support/schemas/custom/show.json +7 -0
- data/test/support/schemas/hyper_schema.json +93 -0
- data/test/support/schemas/render_using_json_api.json +43 -0
- data/test/support/schemas/simple_json_pointers.json +10 -0
- data/test/support/serialization_testing.rb +79 -0
- data/test/test_helper.rb +59 -21
- metadata +529 -43
- data/DESIGN.textile +0 -586
- data/Gemfile.edge +0 -9
- data/bench/perf.rb +0 -43
- data/cruft.md +0 -19
- data/lib/active_model/array_serializer.rb +0 -104
- data/lib/active_model/serializer/associations.rb +0 -233
- data/lib/active_record/serializer_override.rb +0 -16
- data/lib/generators/resource_override.rb +0 -13
- data/lib/generators/serializer/USAGE +0 -9
- data/lib/generators/serializer/serializer_generator.rb +0 -42
- data/lib/generators/serializer/templates/serializer.rb +0 -19
- data/test/association_test.rb +0 -592
- data/test/caching_test.rb +0 -96
- data/test/generators_test.rb +0 -85
- data/test/no_serialization_scope_test.rb +0 -34
- data/test/serialization_scope_name_test.rb +0 -67
- data/test/serialization_test.rb +0 -392
- data/test/serializer_support_test.rb +0 -51
- data/test/serializer_test.rb +0 -1465
- data/test/test_fakes.rb +0 -217
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7232014fa13e7bf11951db024282a8518806ccdd81aead05ce694398e8f16439
|
4
|
+
data.tar.gz: 8337471a240ac4e1931fd71fbfbbf096e8bb5989ce51bce920d2f266aa0ac775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33a114c6a2f87df622d820e8d04b9ce3099891a83f30527d93c159f0014a4fc3a60f883884b6d3a16fa4daf9f65cce1a57410eee4111391351c4199a73e8ca1c
|
7
|
+
data.tar.gz: 5ac71dcb57c2fd16b328cc849b948c6ae0d8cc6d409a1f0b3c942033c439e37c8c8fd8df3be5d80a8a153cb86e38d5cfe93a40fc553f09db739514759ca935a2
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#### Expected behavior vs actual behavior
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
#### Steps to reproduce
|
6
|
+
*(e.g., detailed walkthrough, runnable script, example application)*
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
#### Environment
|
11
|
+
|
12
|
+
ActiveModelSerializers Version *(commit ref if not on tag)*:
|
13
|
+
|
14
|
+
Output of `ruby -e "puts RUBY_DESCRIPTION"`:
|
15
|
+
|
16
|
+
OS Type & Version:
|
17
|
+
|
18
|
+
Integrated application and version *(e.g., Rails, Grape, etc)*:
|
19
|
+
|
20
|
+
|
21
|
+
#### Backtrace
|
22
|
+
*(e.g., provide any applicable backtraces from your application)*
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
#### Additonal helpful information
|
27
|
+
*(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)*
|
28
|
+
|
29
|
+
|
data/.gitignore
CHANGED
@@ -4,15 +4,32 @@
|
|
4
4
|
.config
|
5
5
|
.yardoc
|
6
6
|
Gemfile.lock
|
7
|
+
Gemfile.local
|
7
8
|
InstalledFiles
|
8
9
|
_yardoc
|
9
10
|
coverage
|
10
11
|
doc/
|
11
12
|
lib/bundler/man
|
12
13
|
pkg
|
14
|
+
Vagrantfile
|
15
|
+
.vagrant
|
13
16
|
rdoc
|
14
17
|
spec/reports
|
15
18
|
test/tmp
|
16
19
|
test/version_tmp
|
17
20
|
tmp
|
18
21
|
*.swp
|
22
|
+
.ruby-version
|
23
|
+
.ruby-gemset
|
24
|
+
vendor/bundle
|
25
|
+
tags
|
26
|
+
|
27
|
+
# silly macs
|
28
|
+
.DS_Store
|
29
|
+
.DS_Store?
|
30
|
+
._*
|
31
|
+
.Spotlight-V100
|
32
|
+
.Trashes
|
33
|
+
Icon?
|
34
|
+
ehthumbs.db
|
35
|
+
Thumbs.db
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.1
|
3
|
+
Exclude:
|
4
|
+
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
|
5
|
+
DisplayCopNames: true
|
6
|
+
DisplayStyleGuide: true
|
7
|
+
# https://github.com/bbatsov/rubocop/blob/master/manual/caching.md
|
8
|
+
# https://github.com/bbatsov/rubocop/blob/e8680418b351491e111a18cf5b453fc07a3c5239/config/default.yml#L60-L77
|
9
|
+
UseCache: true
|
10
|
+
CacheRootDirectory: tmp
|
11
|
+
|
12
|
+
Rails:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Lint/NestedMethodDefinition:
|
16
|
+
Enabled: false
|
17
|
+
Exclude:
|
18
|
+
- test/action_controller/serialization_test.rb
|
19
|
+
|
20
|
+
Style/Alias:
|
21
|
+
EnforcedStyle: prefer_alias
|
22
|
+
|
23
|
+
Style/StringLiterals:
|
24
|
+
EnforcedStyle: single_quotes
|
25
|
+
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Max: 35 # TODO: Lower to 15
|
28
|
+
|
29
|
+
Metrics/ClassLength:
|
30
|
+
Max: 261 # TODO: Lower to 100
|
31
|
+
Exclude:
|
32
|
+
- test/**/*.rb
|
33
|
+
|
34
|
+
Metrics/CyclomaticComplexity:
|
35
|
+
Max: 7 # TODO: Lower to 6
|
36
|
+
|
37
|
+
Metrics/LineLength:
|
38
|
+
Max: 251 # TODO: Lower to 80
|
39
|
+
|
40
|
+
Metrics/MethodLength:
|
41
|
+
Max: 106 # TODO: Lower to 10
|
42
|
+
|
43
|
+
Metrics/PerceivedComplexity:
|
44
|
+
Max: 9 # TODO: Lower to 7
|
45
|
+
|
46
|
+
Style/AlignParameters:
|
47
|
+
EnforcedStyle: with_fixed_indentation
|
48
|
+
|
49
|
+
Style/ClassAndModuleChildren:
|
50
|
+
EnforcedStyle: nested
|
51
|
+
|
52
|
+
Style/Documentation:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Style/MissingElse:
|
56
|
+
Enabled: true
|
57
|
+
EnforcedStyle: case
|
58
|
+
|
59
|
+
Style/EmptyElse:
|
60
|
+
EnforcedStyle: empty
|
61
|
+
|
62
|
+
Style/MultilineOperationIndentation:
|
63
|
+
EnforcedStyle: indented
|
64
|
+
|
65
|
+
Style/BlockDelimiters:
|
66
|
+
Enabled: true
|
67
|
+
EnforcedStyle: line_count_based
|
68
|
+
|
69
|
+
Style/SignalException:
|
70
|
+
EnforcedStyle: semantic
|
71
|
+
|
72
|
+
Style/TrailingCommaInLiteral:
|
73
|
+
EnforcedStyleForMultiline: no_comma
|
74
|
+
|
75
|
+
Style/ConditionalAssignment:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Style/DotPosition:
|
79
|
+
EnforcedStyle: leading
|
80
|
+
|
81
|
+
########## test_helper.rb sanity
|
82
|
+
Style/EndBlock:
|
83
|
+
Exclude:
|
84
|
+
- test/test_helper.rb
|
85
|
+
|
86
|
+
Style/SpecialGlobalVars:
|
87
|
+
Exclude:
|
88
|
+
- test/test_helper.rb
|
89
|
+
|
90
|
+
Style/GlobalVars:
|
91
|
+
Exclude:
|
92
|
+
- test/test_helper.rb
|
93
|
+
|
94
|
+
Style/AndOr:
|
95
|
+
Exclude:
|
96
|
+
- test/test_helper.rb
|
97
|
+
- 'lib/active_model/serializer/lint.rb'
|
98
|
+
|
99
|
+
Style/Not:
|
100
|
+
Exclude:
|
101
|
+
- test/test_helper.rb
|
102
|
+
|
103
|
+
Style/ClassCheck:
|
104
|
+
Exclude:
|
105
|
+
- test/test_helper.rb
|
data/.simplecov
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config
|
2
|
+
# see https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb
|
3
|
+
# vim: set ft=ruby
|
4
|
+
|
5
|
+
## DEFINE VARIABLES
|
6
|
+
@minimum_coverage = ENV.fetch('COVERAGE_MINIMUM') {
|
7
|
+
case (defined?(RUBY_ENGINE) && RUBY_ENGINE) || "ruby"
|
8
|
+
when 'jruby', 'rbx'
|
9
|
+
96.0
|
10
|
+
else
|
11
|
+
98.1
|
12
|
+
end
|
13
|
+
}.to_f.round(2)
|
14
|
+
# rubocop:disable Style/DoubleNegation
|
15
|
+
ENV['FULL_BUILD'] ||= ENV['CI']
|
16
|
+
@running_ci = !!(ENV['FULL_BUILD'] =~ /\Atrue\z/i)
|
17
|
+
@generate_report = @running_ci || !!(ENV['COVERAGE'] =~ /\Atrue\z/i)
|
18
|
+
@output = STDOUT
|
19
|
+
# rubocop:enable Style/DoubleNegation
|
20
|
+
|
21
|
+
## CONFIGURE SIMPLECOV
|
22
|
+
|
23
|
+
SimpleCov.profiles.define 'app' do
|
24
|
+
coverage_dir 'coverage'
|
25
|
+
load_profile 'test_frameworks'
|
26
|
+
|
27
|
+
add_group 'Libraries', 'lib'
|
28
|
+
|
29
|
+
add_group 'Long files' do |src_file|
|
30
|
+
src_file.lines.count > 100
|
31
|
+
end
|
32
|
+
class MaxLinesFilter < SimpleCov::Filter
|
33
|
+
def matches?(source_file)
|
34
|
+
source_file.lines.count < filter_argument
|
35
|
+
end
|
36
|
+
end
|
37
|
+
add_group 'Short files', MaxLinesFilter.new(5)
|
38
|
+
|
39
|
+
# Exclude these paths from analysis
|
40
|
+
add_filter '/config/'
|
41
|
+
add_filter '/db/'
|
42
|
+
add_filter 'tasks'
|
43
|
+
add_filter '/.bundle/'
|
44
|
+
end
|
45
|
+
|
46
|
+
## START TRACKING COVERAGE (before activating SimpleCov)
|
47
|
+
require 'coverage'
|
48
|
+
Coverage.start
|
49
|
+
|
50
|
+
## ADD SOME CUSTOM REPORTING AT EXIT
|
51
|
+
SimpleCov.at_exit do
|
52
|
+
next if $! and not ($!.kind_of? SystemExit and $!.success?)
|
53
|
+
|
54
|
+
header = "#{'*' * 20} SimpleCov Results #{'*' * 20}"
|
55
|
+
results = SimpleCov.result.format!.join("\n")
|
56
|
+
exit_message = <<-EOF
|
57
|
+
|
58
|
+
#{header}
|
59
|
+
{{RESULTS}}
|
60
|
+
{{FAILURE_MESSAGE}}
|
61
|
+
|
62
|
+
#{'*' * header.size}
|
63
|
+
EOF
|
64
|
+
percent = Float(SimpleCov.result.covered_percent)
|
65
|
+
if percent < @minimum_coverage
|
66
|
+
failure_message = <<-EOF
|
67
|
+
Spec coverage was not high enough: #{percent.round(2)}% is < #{@minimum_coverage}%
|
68
|
+
EOF
|
69
|
+
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', failure_message)
|
70
|
+
@output.puts exit_message
|
71
|
+
abort(failure_message) if @generate_report
|
72
|
+
elsif @running_ci
|
73
|
+
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', <<-EOF)
|
74
|
+
Nice job! Spec coverage (#{percent.round(2)}%) is still at or above #{@minimum_coverage}%
|
75
|
+
EOF
|
76
|
+
@output.puts exit_message
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start'
|
81
|
+
## to defer running until test/test_helper.rb is loaded.
|
82
|
+
# rubocop:disable Style/MultilineBlockChain
|
83
|
+
AppCoverage = Class.new do
|
84
|
+
def initialize(&block)
|
85
|
+
@block = block
|
86
|
+
end
|
87
|
+
|
88
|
+
def start
|
89
|
+
@block.call
|
90
|
+
end
|
91
|
+
end.new do
|
92
|
+
SimpleCov.start 'app'
|
93
|
+
if @generate_report
|
94
|
+
if @running_ci
|
95
|
+
require 'codeclimate-test-reporter'
|
96
|
+
@output.puts '[COVERAGE] Running with SimpleCov Simple Formatter and CodeClimate Test Reporter'
|
97
|
+
formatters = [
|
98
|
+
SimpleCov::Formatter::SimpleFormatter,
|
99
|
+
CodeClimate::TestReporter::Formatter
|
100
|
+
]
|
101
|
+
else
|
102
|
+
@output.puts '[COVERAGE] Running with SimpleCov HTML Formatter'
|
103
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
104
|
+
end
|
105
|
+
else
|
106
|
+
formatters = []
|
107
|
+
end
|
108
|
+
SimpleCov.formatters = formatters
|
109
|
+
end
|
110
|
+
# rubocop:enable Style/MultilineBlockChain
|
data/.travis.yml
CHANGED
@@ -1,28 +1,54 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
|
4
|
+
cache:
|
5
|
+
directories:
|
6
|
+
- vendor/bundle
|
7
|
+
|
8
|
+
before_install:
|
9
|
+
- "travis_retry gem update --system"
|
10
|
+
- "travis_retry gem update bundler"
|
11
|
+
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
12
|
+
|
13
|
+
script:
|
14
|
+
- bundle exec rake ci
|
15
|
+
after_success:
|
16
|
+
- codeclimate-test-reporter
|
17
|
+
|
18
|
+
env:
|
19
|
+
matrix:
|
20
|
+
- "RAILS_VERSION=4.1"
|
21
|
+
- "RAILS_VERSION=4.2"
|
22
|
+
- "RAILS_VERSION=5.0"
|
23
|
+
- "RAILS_VERSION=5.1"
|
24
|
+
- "RAILS_VERSION=master"
|
25
|
+
|
2
26
|
rvm:
|
3
|
-
- 1.
|
4
|
-
-
|
5
|
-
-
|
6
|
-
- 2.
|
7
|
-
-
|
8
|
-
|
9
|
-
- jruby-19mode
|
10
|
-
- rbx-2
|
11
|
-
gemfile:
|
12
|
-
- Gemfile
|
13
|
-
- Gemfile.edge
|
27
|
+
- 2.1.10
|
28
|
+
- 2.2.8
|
29
|
+
- 2.3.5
|
30
|
+
- 2.4.2
|
31
|
+
- ruby-head
|
32
|
+
|
14
33
|
matrix:
|
15
|
-
|
16
|
-
|
34
|
+
include:
|
35
|
+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
36
|
+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
37
|
+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
38
|
+
# See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
|
39
|
+
# - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
40
|
+
# - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
17
41
|
exclude:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
-
|
28
|
-
|
42
|
+
- { rvm: 2.1.10, env: RAILS_VERSION=master }
|
43
|
+
- { rvm: 2.2.8, env: RAILS_VERSION=master }
|
44
|
+
- { rvm: 2.3.5, env: RAILS_VERSION=master }
|
45
|
+
- { rvm: 2.1.10, env: RAILS_VERSION=5.0 }
|
46
|
+
- { rvm: 2.1.10, env: RAILS_VERSION=5.1 }
|
47
|
+
- { rvm: 2.4.2, env: RAILS_VERSION=4.1 }
|
48
|
+
- { rvm: ruby-head, env: RAILS_VERSION=4.1 }
|
49
|
+
allow_failures:
|
50
|
+
- rvm: ruby-head
|
51
|
+
- rvm: jruby-head
|
52
|
+
# See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
|
53
|
+
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
54
|
+
fast_finish: true
|