pliny 1.3.0 → 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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/bin/pliny-generate +2 -1
  3. data/bin/pliny-new +2 -1
  4. data/bin/pliny-update +2 -1
  5. data/lib/pliny/canonical_log_line_helpers.rb +2 -0
  6. data/lib/pliny/commands/creator.rb +13 -12
  7. data/lib/pliny/commands/generator/base.rb +11 -9
  8. data/lib/pliny/commands/generator/endpoint.rb +19 -17
  9. data/lib/pliny/commands/generator/mediator.rb +7 -5
  10. data/lib/pliny/commands/generator/migration.rb +4 -2
  11. data/lib/pliny/commands/generator/model.rb +11 -9
  12. data/lib/pliny/commands/generator/schema.rb +4 -2
  13. data/lib/pliny/commands/generator/serializer.rb +7 -5
  14. data/lib/pliny/commands/generator.rb +19 -17
  15. data/lib/pliny/commands/updater.rb +5 -3
  16. data/lib/pliny/config_helpers.rb +10 -35
  17. data/lib/pliny/db_support.rb +21 -21
  18. data/lib/pliny/error_reporters/rollbar.rb +5 -3
  19. data/lib/pliny/error_reporters.rb +5 -5
  20. data/lib/pliny/errors.rb +46 -44
  21. data/lib/pliny/helpers/encode.rb +4 -2
  22. data/lib/pliny/helpers/params.rb +2 -0
  23. data/lib/pliny/helpers/serialize.rb +6 -4
  24. data/lib/pliny/helpers/zulu_time.rb +3 -1
  25. data/lib/pliny/log.rb +26 -25
  26. data/lib/pliny/metrics/backends/logger.rb +5 -3
  27. data/lib/pliny/metrics.rb +4 -2
  28. data/lib/pliny/middleware/canonical_log_line.rb +5 -3
  29. data/lib/pliny/middleware/cors.rb +13 -12
  30. data/lib/pliny/middleware/instruments.rb +9 -7
  31. data/lib/pliny/middleware/metrics.rb +3 -1
  32. data/lib/pliny/middleware/request_id.rb +4 -2
  33. data/lib/pliny/middleware/request_store/clear.rb +3 -1
  34. data/lib/pliny/middleware/request_store/seed.rb +3 -1
  35. data/lib/pliny/middleware/rescue_errors.rb +2 -0
  36. data/lib/pliny/middleware/versioning.rb +11 -11
  37. data/lib/pliny/request_store.rb +4 -2
  38. data/lib/pliny/rollbar_logger.rb +6 -4
  39. data/lib/pliny/router.rb +3 -2
  40. data/lib/pliny/tasks/db.rake +3 -1
  41. data/lib/pliny/tasks/schema.rake +3 -1
  42. data/lib/pliny/tasks.rb +2 -0
  43. data/lib/pliny/utils.rb +4 -2
  44. data/lib/pliny/version.rb +3 -1
  45. data/lib/pliny.rb +2 -0
  46. data/lib/template/{.rubocop.yml → .rubocop_template.yml} +1 -5
  47. data/lib/template/Gemfile +6 -4
  48. data/lib/template/Rakefile +1 -0
  49. data/lib/template/bin/console +2 -1
  50. data/lib/template/bin/run +4 -1
  51. data/lib/template/config/config.rb +18 -16
  52. data/lib/template/config/initializers/database.rb +4 -2
  53. data/lib/template/config/initializers/log.rb +2 -0
  54. data/lib/template/config/initializers/metrics.rb +2 -0
  55. data/lib/template/config/puma.rb +3 -1
  56. data/lib/template/config.ru +2 -0
  57. data/lib/template/db/seeds.rb +2 -0
  58. data/lib/template/lib/application.rb +2 -0
  59. data/lib/template/lib/endpoints/base.rb +2 -0
  60. data/lib/template/lib/endpoints/health.rb +2 -0
  61. data/lib/template/lib/endpoints/root.rb +2 -0
  62. data/lib/template/lib/endpoints/schema.rb +2 -0
  63. data/lib/template/lib/initializer.rb +6 -4
  64. data/lib/template/lib/mediators/base.rb +2 -0
  65. data/lib/template/lib/routes.rb +8 -6
  66. data/lib/template/lib/serializers/base.rb +2 -0
  67. data/lib/template/lib/tasks/rubocop.rake +2 -0
  68. data/lib/template/lib/tasks/spec.rake +2 -1
  69. data/lib/template/spec/endpoints/health_spec.rb +2 -0
  70. data/lib/template/spec/endpoints/schema_spec.rb +2 -0
  71. data/lib/template/spec/spec_helper.rb +2 -0
  72. data/lib/template/spec/spec_support/auto_define_rack_app.rb +2 -0
  73. data/lib/template/spec/spec_support/coverage.rb +2 -0
  74. data/lib/template/spec/spec_support/log.rb +2 -0
  75. data/spec/canonical_log_line_helpers_spec.rb +10 -8
  76. data/spec/commands/creator_spec.rb +3 -0
  77. data/spec/commands/generator/base_spec.rb +61 -59
  78. data/spec/commands/generator/endpoint_spec.rb +16 -15
  79. data/spec/commands/generator/mediator_spec.rb +11 -9
  80. data/spec/commands/generator/migration_spec.rb +7 -5
  81. data/spec/commands/generator/model_spec.rb +13 -11
  82. data/spec/commands/generator/schema_spec.rb +29 -28
  83. data/spec/commands/generator/serializer_spec.rb +11 -9
  84. data/spec/commands/generator_spec.rb +64 -62
  85. data/spec/commands/updater_spec.rb +2 -0
  86. data/spec/config_helpers_spec.rb +7 -85
  87. data/spec/db_support_spec.rb +46 -44
  88. data/spec/error_reporters/rollbar_spec.rb +8 -6
  89. data/spec/error_reporters_spec.rb +4 -2
  90. data/spec/errors_spec.rb +4 -1
  91. data/spec/helpers/encode_spec.rb +2 -0
  92. data/spec/helpers/params_spec.rb +9 -7
  93. data/spec/helpers/serialize_spec.rb +11 -7
  94. data/spec/helpers/zulu_time_spec.rb +6 -4
  95. data/spec/integration_spec.rb +14 -12
  96. data/spec/log_spec.rb +8 -6
  97. data/spec/metrics/backends/logger_spec.rb +10 -6
  98. data/spec/metrics_spec.rb +15 -13
  99. data/spec/middleware/canonical_log_line_spec.rb +5 -2
  100. data/spec/middleware/cors_spec.rb +2 -0
  101. data/spec/middleware/instruments_spec.rb +10 -8
  102. data/spec/middleware/metrics_spec.rb +3 -1
  103. data/spec/middleware/request_id_spec.rb +2 -0
  104. data/spec/middleware/request_store/clear_spec.rb +2 -0
  105. data/spec/middleware/request_store/seed_spec.rb +2 -0
  106. data/spec/middleware/rescue_errors_spec.rb +13 -13
  107. data/spec/middleware/versioning_spec.rb +22 -20
  108. data/spec/request_store_spec.rb +3 -1
  109. data/spec/rollbar_logger_spec.rb +11 -9
  110. data/spec/router_spec.rb +9 -7
  111. data/spec/spec_helper.rb +3 -1
  112. data/spec/support/config.rb +2 -0
  113. data/spec/support/endpoints.rb +2 -0
  114. metadata +52 -24
@@ -1,7 +1,9 @@
1
- require 'pliny/commands/creator'
2
- require 'pliny/commands/generator'
3
- require 'pliny/commands/generator/base'
4
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "pliny/commands/creator"
4
+ require "pliny/commands/generator"
5
+ require "pliny/commands/generator/base"
6
+ require "spec_helper"
5
7
 
6
8
  describe Pliny::Commands::Generator do
7
9
  subject { Pliny::Commands::Generator.new }
@@ -25,139 +27,139 @@ describe Pliny::Commands::Generator do
25
27
  Timecop.return
26
28
  end
27
29
 
28
- describe '#endpoint' do
30
+ describe "#endpoint" do
29
31
  before do
30
- subject.endpoint('artists')
32
+ subject.endpoint("artists")
31
33
  end
32
34
 
33
- it 'creates a new endpoint module' do
34
- assert File.exist?('lib/endpoints/artists.rb')
35
+ it "creates a new endpoint module" do
36
+ assert File.exist?("lib/endpoints/artists.rb")
35
37
  end
36
38
 
37
- it 'creates an endpoint test' do
38
- assert File.exist?('spec/endpoints/artists_spec.rb')
39
+ it "creates an endpoint test" do
40
+ assert File.exist?("spec/endpoints/artists_spec.rb")
39
41
  end
40
42
 
41
- it 'creates an endpoint acceptance test' do
42
- assert File.exist?('spec/acceptance/artists_spec.rb')
43
+ it "creates an endpoint acceptance test" do
44
+ assert File.exist?("spec/acceptance/artists_spec.rb")
43
45
  end
44
46
  end
45
47
 
46
- describe '#mediator' do
48
+ describe "#mediator" do
47
49
  before do
48
- subject.mediator('artists/creator')
50
+ subject.mediator("artists/creator")
49
51
  end
50
52
 
51
- it 'creates a new mediator module' do
52
- assert File.exist?('lib/mediators/artists/creator.rb')
53
+ it "creates a new mediator module" do
54
+ assert File.exist?("lib/mediators/artists/creator.rb")
53
55
  end
54
56
 
55
- it 'creates a test' do
56
- assert File.exist?('spec/mediators/artists/creator_spec.rb')
57
+ it "creates a test" do
58
+ assert File.exist?("spec/mediators/artists/creator_spec.rb")
57
59
  end
58
60
  end
59
61
 
60
- describe '#model' do
61
- describe 'simple model' do
62
+ describe "#model" do
63
+ describe "simple model" do
62
64
  before do
63
- subject.model('artist')
65
+ subject.model("artist")
64
66
  end
65
67
 
66
- it 'creates a migration' do
68
+ it "creates a migration" do
67
69
  assert File.exist?("db/migrate/#{@t.to_i}_create_artists.rb")
68
70
  end
69
71
 
70
- it 'creates the actual model' do
71
- assert File.exist?('lib/models/artist.rb')
72
+ it "creates the actual model" do
73
+ assert File.exist?("lib/models/artist.rb")
72
74
  end
73
75
 
74
- it 'creates a test' do
75
- assert File.exist?('spec/models/artist_spec.rb')
76
+ it "creates a test" do
77
+ assert File.exist?("spec/models/artist_spec.rb")
76
78
  end
77
79
  end
78
80
 
79
- describe 'model in nested class' do
81
+ describe "model in nested class" do
80
82
  before do
81
- subject.model('administration/user')
83
+ subject.model("administration/user")
82
84
  end
83
85
 
84
- it 'creates a migration' do
86
+ it "creates a migration" do
85
87
  assert File.exist?("db/migrate/#{@t.to_i}_create_administration_users.rb")
86
88
  end
87
89
 
88
- it 'creates the actual model' do
89
- assert File.exist?('lib/models/administration/user.rb')
90
+ it "creates the actual model" do
91
+ assert File.exist?("lib/models/administration/user.rb")
90
92
  end
91
93
 
92
- it 'creates a test' do
93
- assert File.exist?('spec/models/administration/user_spec.rb')
94
+ it "creates a test" do
95
+ assert File.exist?("spec/models/administration/user_spec.rb")
94
96
  end
95
97
  end
96
98
  end
97
99
 
98
- describe '#scaffold' do
100
+ describe "#scaffold" do
99
101
  before do
100
- subject.scaffold('artist')
102
+ subject.scaffold("artist")
101
103
  end
102
104
 
103
- it 'creates a new endpoint module' do
104
- assert File.exist?('lib/endpoints/artists.rb')
105
+ it "creates a new endpoint module" do
106
+ assert File.exist?("lib/endpoints/artists.rb")
105
107
  end
106
108
 
107
- it 'creates an endpoint test' do
108
- assert File.exist?('spec/endpoints/artists_spec.rb')
109
+ it "creates an endpoint test" do
110
+ assert File.exist?("spec/endpoints/artists_spec.rb")
109
111
  end
110
112
 
111
- it 'creates an endpoint acceptance test' do
112
- assert File.exist?('spec/acceptance/artists_spec.rb')
113
+ it "creates an endpoint acceptance test" do
114
+ assert File.exist?("spec/acceptance/artists_spec.rb")
113
115
  end
114
116
 
115
- it 'creates a migration' do
117
+ it "creates a migration" do
116
118
  assert File.exist?("db/migrate/#{@t.to_i}_create_artists.rb")
117
119
  end
118
120
 
119
- it 'creates the actual model' do
120
- assert File.exist?('lib/models/artist.rb')
121
+ it "creates the actual model" do
122
+ assert File.exist?("lib/models/artist.rb")
121
123
  end
122
124
 
123
- it 'creates a test' do
124
- assert File.exist?('spec/models/artist_spec.rb')
125
+ it "creates a test" do
126
+ assert File.exist?("spec/models/artist_spec.rb")
125
127
  end
126
128
 
127
- it 'creates a schema' do
128
- assert File.exist?('schema/schemata/artist.yaml')
129
+ it "creates a schema" do
130
+ assert File.exist?("schema/schemata/artist.yaml")
129
131
  end
130
132
 
131
- it 'creates a new serializer module' do
132
- assert File.exist?('lib/serializers/artist.rb')
133
+ it "creates a new serializer module" do
134
+ assert File.exist?("lib/serializers/artist.rb")
133
135
  end
134
136
 
135
- it 'creates a test' do
136
- assert File.exist?('spec/serializers/artist_spec.rb')
137
+ it "creates a test" do
138
+ assert File.exist?("spec/serializers/artist_spec.rb")
137
139
  end
138
140
  end
139
141
 
140
- describe '#schema' do
142
+ describe "#schema" do
141
143
  before do
142
- subject.schema('artist')
144
+ subject.schema("artist")
143
145
  end
144
146
 
145
- it 'creates a schema' do
146
- assert File.exist?('schema/schemata/artist.yaml')
147
+ it "creates a schema" do
148
+ assert File.exist?("schema/schemata/artist.yaml")
147
149
  end
148
150
  end
149
151
 
150
- describe '#serializer' do
152
+ describe "#serializer" do
151
153
  before do
152
- subject.serializer('artist')
154
+ subject.serializer("artist")
153
155
  end
154
156
 
155
- it 'creates a new serializer module' do
156
- assert File.exist?('lib/serializers/artist.rb')
157
+ it "creates a new serializer module" do
158
+ assert File.exist?("lib/serializers/artist.rb")
157
159
  end
158
160
 
159
- it 'creates a test' do
160
- assert File.exist?('spec/serializers/artist_spec.rb')
161
+ it "creates a test" do
162
+ assert File.exist?("spec/serializers/artist_spec.rb")
161
163
  end
162
164
  end
163
165
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pliny/commands/updater"
2
4
  require "spec_helper"
3
5
 
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "pliny/config_helpers"
3
5
 
4
6
  describe Pliny::CastingConfigHelpers do
5
-
6
7
  describe "#rack_env" do
7
8
  it "is development if app_env is development" do
8
9
  config = Class.new do
9
10
  extend Pliny::CastingConfigHelpers
10
- override :app_env, 'development', string
11
+ override :app_env, "development", string
11
12
  end
12
13
 
13
14
  assert_equal "development", config.rack_env
@@ -16,7 +17,7 @@ describe Pliny::CastingConfigHelpers do
16
17
  it "is development if app_env is test" do
17
18
  config = Class.new do
18
19
  extend Pliny::CastingConfigHelpers
19
- override :app_env, 'test', string
20
+ override :app_env, "test", string
20
21
  end
21
22
 
22
23
  assert_equal "development", config.rack_env
@@ -25,7 +26,7 @@ describe Pliny::CastingConfigHelpers do
25
26
  it "is deployment if app_env is production" do
26
27
  config = Class.new do
27
28
  extend Pliny::CastingConfigHelpers
28
- override :app_env, 'production', string
29
+ override :app_env, "production", string
29
30
  end
30
31
 
31
32
  assert_equal "deployment", config.rack_env
@@ -34,7 +35,7 @@ describe Pliny::CastingConfigHelpers do
34
35
  it "is deployment if app_env is nil" do
35
36
  config = Class.new do
36
37
  extend Pliny::CastingConfigHelpers
37
- override :app_env, '', string
38
+ override :app_env, "", string
38
39
  end
39
40
 
40
41
  assert_equal "deployment", config.rack_env
@@ -43,89 +44,10 @@ describe Pliny::CastingConfigHelpers do
43
44
  it "is deployment if app_env is another value" do
44
45
  config = Class.new do
45
46
  extend Pliny::CastingConfigHelpers
46
- override :app_env, 'staging', string
47
+ override :app_env, "staging", string
47
48
  end
48
49
 
49
50
  assert_equal "deployment", config.rack_env
50
51
  end
51
-
52
- context "when legacy PLINY_ENV is still defined" do
53
- before do
54
- ENV['ORIGINAL_PLINY_ENV'] = ENV['PLINY_ENV']
55
- ENV['PLINY_ENV'] = 'staging'
56
- end
57
-
58
- after do
59
- ENV['PLINY_ENV'] = ENV.delete('ORIGINAL_PLINY_ENV')
60
- end
61
-
62
- it "uses PLINY_ENV value instead of APP_ENV" do
63
- config = Class.new do
64
- extend Pliny::CastingConfigHelpers
65
- override :app_env, 'development', string
66
- end
67
-
68
- assert_equal "deployment", config.rack_env
69
- end
70
-
71
- it "displays deprecation warning" do
72
- config = Class.new do
73
- extend Pliny::CastingConfigHelpers
74
- override :app_env, 'development', string
75
- end
76
-
77
- io = StringIO.new
78
- $stderr = io
79
- config.rack_env
80
- $stderr = STDERR
81
-
82
- assert_includes io.string, "PLINY_ENV is deprecated"
83
- end
84
- end
85
- end
86
-
87
- describe "#pliny_env" do
88
- it "displays deprecation warning if pliny_env is used" do
89
- config = Class.new do
90
- extend Pliny::CastingConfigHelpers
91
- override :app_env, 'development', string
92
- end
93
-
94
- io = StringIO.new
95
- $stderr = io
96
- config.pliny_env
97
- $stderr = STDERR
98
-
99
- assert_includes io.string, "Config.pliny_env is deprecated"
100
- end
101
-
102
- it "returns app_env value" do
103
- config = Class.new do
104
- extend Pliny::CastingConfigHelpers
105
- override :app_env, 'foo', string
106
- end
107
-
108
- assert_equal "foo", config.pliny_env
109
- end
110
-
111
- context "when legacy PLINY_ENV is still defined" do
112
- before do
113
- ENV['ORIGINAL_PLINY_ENV'] = ENV['PLINY_ENV']
114
- ENV['PLINY_ENV'] = 'staging'
115
- end
116
-
117
- after do
118
- ENV['PLINY_ENV'] = ENV.delete('ORIGINAL_PLINY_ENV')
119
- end
120
-
121
- it "returns PLINY_ENV value" do
122
- config = Class.new do
123
- extend Pliny::CastingConfigHelpers
124
- override :app_env, 'development', string
125
- end
126
-
127
- assert_equal "staging", config.pliny_env
128
- end
129
- end
130
52
  end
131
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "pliny/db_support"
3
5
 
@@ -176,8 +178,8 @@ describe Pliny::DbSupport do
176
178
  end
177
179
  end
178
180
 
179
- describe 'MigrationStatusPresenter' do
180
- let(:filename) { '1630551344_latest_change.rb' }
181
+ describe "MigrationStatusPresenter" do
182
+ let(:filename) { "1630551344_latest_change.rb" }
181
183
  let(:up_migration) { described_class::MigrationStatus.new(filename: "00#{filename}") }
182
184
  let(:down_migration) { described_class::MigrationStatus.new(filename: "0#{filename}") }
183
185
  let(:file_missing_migration) { described_class::MigrationStatus.new(filename: "000#{filename}") }
@@ -193,79 +195,79 @@ describe Pliny::DbSupport do
193
195
  file_missing_migration.present_on_disk = false
194
196
  end
195
197
 
196
- describe '#barrier_row' do
197
- it 'pads to the longest_migration name' do
198
- expectation = '+--------------+--------------------------------+'
198
+ describe "#barrier_row" do
199
+ it "pads to the longest_migration name" do
200
+ expectation = "+--------------+--------------------------------+"
199
201
  assert_equal expectation, presenter.barrier_row
200
202
  end
201
203
  end
202
204
 
203
- describe '#header_row' do
204
- it 'pads to the longest migration name' do
205
- expectation = '| STATUS | MIGRATION |'
205
+ describe "#header_row" do
206
+ it "pads to the longest migration name" do
207
+ expectation = "| STATUS | MIGRATION |"
206
208
  assert_equal expectation, presenter.header_row
207
209
  end
208
210
  end
209
211
 
210
- describe '#header' do
211
- let(:barrier) { '+--------------+--------------------------------+' }
212
- let(:header) { '| STATUS | MIGRATION |' }
212
+ describe "#header" do
213
+ let(:barrier) { "+--------------+--------------------------------+" }
214
+ let(:header) { "| STATUS | MIGRATION |" }
213
215
 
214
- it 'wraps the title in barriers' do
216
+ it "wraps the title in barriers" do
215
217
  assert_equal [barrier, header, barrier], presenter.header
216
218
  end
217
219
  end
218
220
 
219
- describe '#footer' do
220
- let(:barrier) { '+--------------+--------------------------------+' }
221
+ describe "#footer" do
222
+ let(:barrier) { "+--------------+--------------------------------+" }
221
223
 
222
- it 'just a barrier' do
224
+ it "just a barrier" do
223
225
  assert_equal [barrier], presenter.footer
224
226
  end
225
227
  end
226
228
 
227
- describe '#status_row' do
228
- context 'an up migration' do
229
- it 'shows the correct details' do
230
- expectation = '| UP | 001630551344_latest_change.rb |'
229
+ describe "#status_row" do
230
+ context "an up migration" do
231
+ it "shows the correct details" do
232
+ expectation = "| UP | 001630551344_latest_change.rb |"
231
233
  assert_equal expectation, presenter.status_row(up_migration)
232
234
  end
233
235
  end
234
236
 
235
- context 'a down migration' do
236
- it 'shows the correct details' do
237
- expectation = '| DOWN | 01630551344_latest_change.rb |'
237
+ context "a down migration" do
238
+ it "shows the correct details" do
239
+ expectation = "| DOWN | 01630551344_latest_change.rb |"
238
240
  assert_equal expectation, presenter.status_row(down_migration)
239
241
  end
240
242
  end
241
243
 
242
- context 'a file missing migration' do
243
- it 'shows the correct details' do
244
- expectation = '| FILE MISSING | 0001630551344_latest_change.rb |'
244
+ context "a file missing migration" do
245
+ it "shows the correct details" do
246
+ expectation = "| FILE MISSING | 0001630551344_latest_change.rb |"
245
247
  assert_equal expectation, presenter.status_row(file_missing_migration)
246
248
  end
247
249
  end
248
250
  end
249
251
 
250
- describe '#statuses' do
251
- let(:up_expectation) { '| UP | 001630551344_latest_change.rb |' }
252
- let(:down_expectation) { '| DOWN | 01630551344_latest_change.rb |' }
253
- let(:file_missing_expectation) { '| FILE MISSING | 0001630551344_latest_change.rb |' }
252
+ describe "#statuses" do
253
+ let(:up_expectation) { "| UP | 001630551344_latest_change.rb |" }
254
+ let(:down_expectation) { "| DOWN | 01630551344_latest_change.rb |" }
255
+ let(:file_missing_expectation) { "| FILE MISSING | 0001630551344_latest_change.rb |" }
254
256
 
255
- it 'returns strings' do
257
+ it "returns strings" do
256
258
  assert_equal [up_expectation, down_expectation, file_missing_expectation], presenter.statuses
257
259
  end
258
260
  end
259
261
 
260
- describe '#rows' do
261
- let(:barrier) { '+--------------+--------------------------------+' }
262
- let(:header) { '| STATUS | MIGRATION |' }
263
- let(:up_expectation) { '| UP | 001630551344_latest_change.rb |' }
264
- let(:down_expectation) { '| DOWN | 01630551344_latest_change.rb |' }
265
- let(:file_missing_expectation) { '| FILE MISSING | 0001630551344_latest_change.rb |' }
266
- let(:footer) { '+--------------+--------------------------------+' }
262
+ describe "#rows" do
263
+ let(:barrier) { "+--------------+--------------------------------+" }
264
+ let(:header) { "| STATUS | MIGRATION |" }
265
+ let(:up_expectation) { "| UP | 001630551344_latest_change.rb |" }
266
+ let(:down_expectation) { "| DOWN | 01630551344_latest_change.rb |" }
267
+ let(:file_missing_expectation) { "| FILE MISSING | 0001630551344_latest_change.rb |" }
268
+ let(:footer) { "+--------------+--------------------------------+" }
267
269
 
268
- it 'is the table as an array' do
270
+ it "is the table as an array" do
269
271
  expectation = [
270
272
  barrier,
271
273
  header,
@@ -273,15 +275,15 @@ describe Pliny::DbSupport do
273
275
  up_expectation,
274
276
  down_expectation,
275
277
  file_missing_expectation,
276
- footer
278
+ footer,
277
279
  ]
278
280
 
279
281
  assert_equal expectation, presenter.rows
280
282
  end
281
283
  end
282
284
 
283
- describe '#to_s' do
284
- it 'is the table as a string' do
285
+ describe "#to_s" do
286
+ it "is the table as a string" do
285
287
  expectation = <<~OUTPUT.chomp
286
288
  +--------------+--------------------------------+
287
289
  | STATUS | MIGRATION |
@@ -297,8 +299,8 @@ describe Pliny::DbSupport do
297
299
  end
298
300
  end
299
301
 
300
- describe '#status' do
301
- let(:filename) { '1630551344_latest_change.rb' }
302
+ describe "#status" do
303
+ let(:filename) { "1630551344_latest_change.rb" }
302
304
  let(:up_migration) { "00#{filename}" }
303
305
  let(:down_migration) { "0#{filename}" }
304
306
  let(:file_missing_migration) { "000#{filename}" }
@@ -339,7 +341,7 @@ describe Pliny::DbSupport do
339
341
  end
340
342
  end
341
343
 
342
- it 'returns a table string' do
344
+ it "returns a table string" do
343
345
  expectation = <<~OUTPUT.chomp
344
346
  +--------------+--------------------------------+
345
347
  | STATUS | MIGRATION |
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "rollbar"
3
5
  require "pliny/error_reporters/rollbar"
@@ -7,8 +9,8 @@ describe Pliny::ErrorReporters::Rollbar do
7
9
 
8
10
  describe "#notify" do
9
11
  let(:exception) { StandardError.new("Something went wrong") }
10
- let(:context) { { step: :foo } }
11
- let(:rack_env) { { "rack.input" => StringIO.new } }
12
+ let(:context) { { step: :foo } }
13
+ let(:rack_env) { { "rack.input" => StringIO.new } }
12
14
 
13
15
  subject(:notify) do
14
16
  reporter.notify(exception, context: context, rack_env: rack_env)
@@ -29,7 +31,7 @@ describe Pliny::ErrorReporters::Rollbar do
29
31
  notify
30
32
  expect(::Rollbar).to have_received(:scoped).once.with(hash_including(
31
33
  request: instance_of(Proc),
32
- custom: { step: :foo }
34
+ custom: { step: :foo },
33
35
  ))
34
36
  end
35
37
 
@@ -38,8 +40,8 @@ describe Pliny::ErrorReporters::Rollbar do
38
40
  { "rollbar.person_data" => {
39
41
  id: SecureRandom.uuid,
40
42
  email: "foo@bar.com",
41
- username: "foo"
42
- }}
43
+ username: "foo",
44
+ } }
43
45
  end
44
46
 
45
47
  it "adds person to the rollbar notification" do
@@ -66,7 +68,7 @@ describe Pliny::ErrorReporters::Rollbar do
66
68
 
67
69
  it "reports to Rollbar without request data in the scope" do
68
70
  notify
69
- expect(Rollbar).to have_received(:scoped).once.with({ custom: {step: :foo} })
71
+ expect(Rollbar).to have_received(:scoped).once.with({ custom: { step: :foo } })
70
72
  end
71
73
 
72
74
  it "delegates to #report_exception_to_rollbar" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Pliny::ErrorReporters do
@@ -7,8 +9,8 @@ describe Pliny::ErrorReporters do
7
9
 
8
10
  describe ".notify" do
9
11
  let(:exception) { RuntimeError.new }
10
- let(:context) { { context: "foo" } }
11
- let(:rack_env) { { rack_env: "bar" } }
12
+ let(:context) { { context: "foo" } }
13
+ let(:rack_env) { { rack_env: "bar" } }
12
14
 
13
15
  subject(:notify_reporter) do
14
16
  reporter.notify(exception, context: context, rack_env: rack_env)
data/spec/errors_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Pliny::Errors do
@@ -9,7 +11,8 @@ describe Pliny::Errors do
9
11
 
10
12
  it "includes an HTTP error that will take generic parameters" do
11
13
  e = Pliny::Errors::HTTPStatusError.new(
12
- "Custom HTTP error.", :custom_http_error, 499)
14
+ "Custom HTTP error.", :custom_http_error, 499,
15
+ )
13
16
  assert_equal "Custom HTTP error.", e.message
14
17
  assert_equal :custom_http_error, e.id
15
18
  assert_equal 499, e.status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Pliny::Helpers::Encode do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe Pliny::Helpers::Params do
@@ -11,35 +13,35 @@ describe Pliny::Helpers::Params do
11
13
  end
12
14
 
13
15
  it "loads json params" do
14
- post "/", {hello: "world"}.to_json, {"CONTENT_TYPE" => "application/json"}
16
+ post "/", { hello: "world" }.to_json, { "CONTENT_TYPE" => "application/json" }
15
17
  assert_equal "{\"hello\":\"world\"}", last_response.body
16
18
  end
17
19
 
18
20
  it "loads json array of params" do
19
- post "/", [{hello: "world"}, {goodbye: "moon"}].to_json, {"CONTENT_TYPE" => "application/json"}
21
+ post "/", [{ hello: "world" }, { goodbye: "moon" }].to_json, { "CONTENT_TYPE" => "application/json" }
20
22
  assert_equal "[{\"hello\":\"world\"},{\"goodbye\":\"moon\"}]", last_response.body
21
23
  end
22
24
 
23
25
  it "loads json array of arrays of params" do
24
- post "/", [[{hello: "world"}], [{goodbye: "moon"}]].to_json, {"CONTENT_TYPE" => "application/json"}
26
+ post "/", [[{ hello: "world" }], [{ goodbye: "moon" }]].to_json, { "CONTENT_TYPE" => "application/json" }
25
27
  assert_equal "[[{\"hello\":\"world\"}],[{\"goodbye\":\"moon\"}]]", last_response.body
26
28
  end
27
29
 
28
30
  it "loads form data params" do
29
- post "/", {hello: "world"}
31
+ post "/", { hello: "world" }
30
32
  assert_equal "{\"hello\":\"world\"}", last_response.body
31
33
  end
32
34
 
33
35
  it "loads from an unknown content type" do
34
- post "/", "<hello>world</hello>", {"CONTENT_TYPE" => "application/xml"}
36
+ post "/", "<hello>world</hello>", { "CONTENT_TYPE" => "application/xml" }
35
37
  assert_equal "{}", last_response.body
36
38
  end
37
39
 
38
40
  it "should throw bad request when receiving invalid json via post" do
39
41
  err = assert_raises(Pliny::Errors::BadRequest) do
40
- post "/", "{\"foo\"}", {"CONTENT_TYPE" => "application/json"}
42
+ post "/", "{\"foo\"}", { "CONTENT_TYPE" => "application/json" }
41
43
  end
42
44
 
43
- assert_match /unexpected token/, err.message
45
+ assert_match(/expected ':' after object key at line 1 column 7/, err.message)
44
46
  end
45
47
  end