mercy 1.6.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +74 -12
- data/.claude/agents/architect.md +48 -0
- data/.claude/agents/infra.md +36 -0
- data/.claude/agents/ruby.md +45 -0
- data/.claude/configuration/arcanum-repo-config.json +3 -0
- data/.claude/scripts/check_infra.sh +6 -0
- data/.claude/scripts/check_ruby.sh +7 -0
- data/.claude/settings.json +10 -0
- data/.github/commit_message_template-2.0.md +32 -0
- data/.github/commit_message_template.md +10 -0
- data/.github/copilot-instructions.md +1 -0
- data/.github/pull_request_template.md +17 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +38 -1
- data/.rubocop_todo.yml +6 -317
- data/AGENTS.md +58 -0
- data/CLAUDE.md +1 -0
- data/Dockerfile +18 -3
- data/Gemfile +26 -1
- data/README.md +8 -4
- data/Rakefile +3 -0
- data/config/check_specs.yml +7 -0
- data/config/yardstick.yml +11 -3
- data/docs/agents/arcanum-split-issue.md +9 -0
- data/docs/agents/architecture.md +61 -0
- data/docs/agents/contributing.md +195 -0
- data/docs/agents/flow.md +5 -0
- data/docs/agents/folder-structure.md +26 -0
- data/docs/agents/issue-enhancement.md +10 -0
- data/docs/agents/issues/.gitkeep +1 -0
- data/docs/agents/plans/.gitkeep +1 -0
- data/lib/arstotzka/type_cast_ext.rb +52 -2
- data/lib/mercy/class_methods.rb +77 -7
- data/lib/mercy/concern.rb +105 -1
- data/lib/mercy/period_parser.rb +46 -3
- data/lib/mercy/report/active_record.rb +20 -16
- data/lib/mercy/report/error.rb +6 -4
- data/lib/mercy/report/multiple.rb +26 -22
- data/lib/mercy/report/range.rb +6 -4
- data/lib/mercy/report.rb +38 -7
- data/lib/mercy/report_builder.rb +2 -0
- data/lib/mercy/report_config.rb +5 -0
- data/lib/mercy/status.rb +7 -1
- data/lib/mercy/status_builder.rb +2 -0
- data/lib/mercy/version.rb +3 -1
- data/lib/mercy.rb +2 -0
- data/mercy.gemspec +14 -27
- data/scripts/bump_version.sh +62 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +10 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/document_report_controller.rb +34 -0
- data/spec/dummy/app/controllers/example_report_controller.rb +27 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/jobs/application_job.rb +4 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/document.rb +9 -0
- data/spec/dummy/app/models/dummy_report.rb +6 -0
- data/spec/dummy/app/models/mercy/report/doc_type_error.rb +20 -0
- data/spec/dummy/app/models/mercy/report/dummy1.rb +19 -0
- data/spec/dummy/app/models/mercy/report/dummy_report.rb +11 -0
- data/spec/dummy/app/models/mercy/report/multiple/dummy.rb +28 -0
- data/spec/dummy/app/models/mercy/report/multiple/successes.rb +28 -0
- data/spec/dummy/app/models/mercy/report/success.rb +18 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +5 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +38 -0
- data/spec/dummy/bin/update +33 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +24 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +20 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +55 -0
- data/spec/dummy/config/environments/production.rb +95 -0
- data/spec/dummy/config/environments/test.rb +52 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +27 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +18 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +36 -0
- data/spec/dummy/config/routes.rb +16 -0
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/db/migrate/20190508170435_create_documents.rb +13 -0
- data/spec/dummy/db/schema.rb +27 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/dummy/tmp/.keep +0 -0
- data/spec/dummy/tmp/storage/.keep +0 -0
- data/spec/integration/controller/error_report_controller_spec.rb +196 -0
- data/spec/integration/controller/multiple_report_spec.rb +86 -0
- data/spec/integration/controller/range_report_spec.rb +194 -0
- data/spec/integration/yard/arstotzka/type_cast_spec.rb +43 -0
- data/spec/integration/yard/controller/example_report_controller_spec.rb +95 -0
- data/spec/integration/yard/mercy/period_parser_spec.rb +21 -0
- data/spec/lib/arstotzka/type_cast_spec.rb +10 -9
- data/spec/lib/mercy/period_parser_spec.rb +10 -9
- data/spec/lib/mercy/report/error_spec.rb +93 -70
- data/spec/lib/mercy/report/multiple_spec.rb +9 -57
- data/spec/lib/mercy/report/range_spec.rb +70 -41
- data/spec/lib/mercy/report_builder_spec.rb +34 -17
- data/spec/lib/mercy/report_config_spec.rb +48 -0
- data/spec/lib/mercy/report_spec.rb +5 -15
- data/spec/lib/mercy/status_builder_spec.rb +33 -22
- data/spec/lib/mercy/status_spec.rb +69 -49
- data/spec/spec_helper.rb +18 -7
- data/spec/support/fixture_helpers.rb +4 -2
- data/spec/support/models/arstotzka/type_cast/dummy.rb +9 -0
- data/spec/support/shared_contexts/document_setup.rb +31 -0
- data/spec/support/shared_examples/time_parser.rb +2 -0
- metadata +113 -191
- data/spec/lib/mercy/report/report_config_spec.rb +0 -39
- data/spec/support/models/document.rb +0 -6
- data/spec/support/report/dummy.rb +0 -15
- data/spec/support/schema.rb +0 -11
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe DocumentReportController, type: :controller do
|
|
6
|
+
describe 'range reports' do
|
|
7
|
+
let(:parameters) { {} }
|
|
8
|
+
|
|
9
|
+
let(:successes) { 0 }
|
|
10
|
+
let(:errors) { 0 }
|
|
11
|
+
let(:old_successes) { 11 }
|
|
12
|
+
let(:old_errors) { 11 }
|
|
13
|
+
|
|
14
|
+
let(:expected_status) { 'ok' }
|
|
15
|
+
let(:expected_total_count) { 0 }
|
|
16
|
+
let(:expected_total_status) { 'ok' }
|
|
17
|
+
let(:expected_error_count) { 0 }
|
|
18
|
+
let(:expected_error_status) { 'ok' }
|
|
19
|
+
|
|
20
|
+
let(:parsed_response) do
|
|
21
|
+
JSON.parse(response.body)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:expected_response) do
|
|
25
|
+
{
|
|
26
|
+
status: expected_status,
|
|
27
|
+
total: {
|
|
28
|
+
count: expected_total_count,
|
|
29
|
+
status: expected_total_status
|
|
30
|
+
},
|
|
31
|
+
error: {
|
|
32
|
+
count: expected_error_count,
|
|
33
|
+
status: expected_error_status
|
|
34
|
+
}
|
|
35
|
+
}.deep_stringify_keys
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
before do
|
|
39
|
+
Document.delete_all
|
|
40
|
+
|
|
41
|
+
successes.times { Document.with_success.create }
|
|
42
|
+
errors.times { Document.with_error.create }
|
|
43
|
+
old_successes.times do
|
|
44
|
+
Document.with_success.create(updated_at: 1.day.ago)
|
|
45
|
+
end
|
|
46
|
+
old_errors.times do
|
|
47
|
+
Document.with_error.create(updated_at: 1.day.ago)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
get :range_status, params: parameters
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context 'when there are no documents for the given period' do
|
|
54
|
+
let(:old_successes) { 10 }
|
|
55
|
+
let(:expected_status) { 'error' }
|
|
56
|
+
let(:expected_total_status) { 'error' }
|
|
57
|
+
|
|
58
|
+
it 'fails on minimum' do
|
|
59
|
+
expect(response.status).to eq(500)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'returns status json' do
|
|
63
|
+
expect(parsed_response).to eq(expected_response)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context 'when there are errors below the maximum' do
|
|
68
|
+
let(:errors) { 8 }
|
|
69
|
+
let(:successes) { 11 }
|
|
70
|
+
|
|
71
|
+
let(:expected_total_count) { 19 }
|
|
72
|
+
let(:expected_error_count) { 8 }
|
|
73
|
+
|
|
74
|
+
it 'does not fail' do
|
|
75
|
+
expect(response).to be_successful
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'returns status json' do
|
|
79
|
+
expect(parsed_response).to eq(expected_response)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context 'when there are errors above the maximum' do
|
|
84
|
+
let(:errors) { 11 }
|
|
85
|
+
let(:successes) { 11 }
|
|
86
|
+
|
|
87
|
+
let(:expected_total_count) { 22 }
|
|
88
|
+
let(:expected_error_count) { 11 }
|
|
89
|
+
let(:expected_status) { 'error' }
|
|
90
|
+
let(:expected_error_status) { 'error' }
|
|
91
|
+
|
|
92
|
+
it 'fails due to maximum threshold' do
|
|
93
|
+
expect(response.status).to eq(500)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'returns status json' do
|
|
97
|
+
expect(parsed_response).to eq(expected_response)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context 'when passing params' do
|
|
102
|
+
context 'when passing period' do
|
|
103
|
+
let(:parameters) { { period: '2days' } }
|
|
104
|
+
|
|
105
|
+
let(:expected_status) { 'error' }
|
|
106
|
+
let(:expected_total_count) { 22 }
|
|
107
|
+
let(:expected_total_status) { 'ok' }
|
|
108
|
+
let(:expected_error_count) { 11 }
|
|
109
|
+
let(:expected_error_status) { 'error' }
|
|
110
|
+
|
|
111
|
+
it 'fails due to maximum threshold' do
|
|
112
|
+
expect(response.status).to eq(500)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'returns status json' do
|
|
116
|
+
expect(parsed_response).to eq(expected_response)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
context 'when passing a minimum' do
|
|
121
|
+
let(:parameters) { { minimum: 3 } }
|
|
122
|
+
|
|
123
|
+
context 'when minimun is reached' do
|
|
124
|
+
let(:errors) { 4 }
|
|
125
|
+
let(:successes) { 1 }
|
|
126
|
+
|
|
127
|
+
let(:expected_total_count) { 5 }
|
|
128
|
+
let(:expected_error_count) { 4 }
|
|
129
|
+
|
|
130
|
+
it 'does not fail' do
|
|
131
|
+
expect(response).to be_successful
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'returns status json' do
|
|
135
|
+
expect(parsed_response).to eq(expected_response)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context 'when minimun is not reached' do
|
|
140
|
+
let(:expected_status) { 'error' }
|
|
141
|
+
let(:expected_total_status) { 'error' }
|
|
142
|
+
let(:expected_error_status) { 'error' }
|
|
143
|
+
|
|
144
|
+
it 'fails on error due to minimum' do
|
|
145
|
+
expect(response.status).to eq(500)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'returns status json' do
|
|
149
|
+
expect(parsed_response).to eq(expected_response)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
context 'when passing a maximum' do
|
|
155
|
+
let(:parameters) { { maximum: 5 } }
|
|
156
|
+
|
|
157
|
+
context 'when maximum is not reached' do
|
|
158
|
+
let(:errors) { 2 }
|
|
159
|
+
let(:successes) { 3 }
|
|
160
|
+
|
|
161
|
+
let(:expected_total_count) { 5 }
|
|
162
|
+
let(:expected_error_count) { 2 }
|
|
163
|
+
|
|
164
|
+
it 'does not fail' do
|
|
165
|
+
expect(response).to be_successful
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'returns status json' do
|
|
169
|
+
expect(parsed_response).to eq(expected_response)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context 'when maximum is reached' do
|
|
174
|
+
let(:errors) { 11 }
|
|
175
|
+
let(:successes) { 1 }
|
|
176
|
+
|
|
177
|
+
let(:expected_total_count) { 12 }
|
|
178
|
+
let(:expected_error_count) { 11 }
|
|
179
|
+
let(:expected_status) { 'error' }
|
|
180
|
+
let(:expected_total_status) { 'error' }
|
|
181
|
+
let(:expected_error_status) { 'error' }
|
|
182
|
+
|
|
183
|
+
it 'fails on error due to minimum' do
|
|
184
|
+
expect(response.status).to eq(500)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it 'returns status json' do
|
|
188
|
+
expect(parsed_response).to eq(expected_response)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Arstotzka::TypeCast do
|
|
6
|
+
describe 'yard' do
|
|
7
|
+
subject(:caster) { described_class::Dummy }
|
|
8
|
+
|
|
9
|
+
describe '.to_period' do
|
|
10
|
+
it do
|
|
11
|
+
expect(caster.to_period('2days')).to be_a(Integer)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'converts string to period' do
|
|
15
|
+
expect(caster.to_period('2days')).to eq(2.days)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '.to_infinity_float' do
|
|
20
|
+
it do
|
|
21
|
+
expect(caster.to_infinity_float('-0.75')).to be_a(Float)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'converts to float' do
|
|
25
|
+
expect(caster.to_infinity_float('-0.75')).to eq(-0.75)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'when converting infinity' do
|
|
29
|
+
it 'converts to float' do
|
|
30
|
+
expect(caster.to_infinity_float('inf'))
|
|
31
|
+
.to eq(Float::INFINITY)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'when converting negative infinity' do
|
|
36
|
+
it 'converts to float' do
|
|
37
|
+
expect(caster.to_infinity_float('-inf'))
|
|
38
|
+
.to eq(-Float::INFINITY)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ExampleReportController, type: :controller do
|
|
6
|
+
let(:parsed_response) do
|
|
7
|
+
JSON.parse(response.body)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe 'status' do
|
|
11
|
+
let(:expected_response) do
|
|
12
|
+
{
|
|
13
|
+
'status' => 'error',
|
|
14
|
+
'errors_a' => {
|
|
15
|
+
'ids' => [10],
|
|
16
|
+
'percentage' => 0.02,
|
|
17
|
+
'status' => 'ok'
|
|
18
|
+
},
|
|
19
|
+
'errors_b' => {
|
|
20
|
+
'ids' => [20],
|
|
21
|
+
'percentage' => 0.25,
|
|
22
|
+
'status' => 'error'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let(:a_successes) { 49 }
|
|
28
|
+
let(:b_successes) { 3 }
|
|
29
|
+
|
|
30
|
+
before do
|
|
31
|
+
Document.delete_all
|
|
32
|
+
a_successes.times { Document.create(doc_type: :a) }
|
|
33
|
+
b_successes.times { Document.create(doc_type: :b) }
|
|
34
|
+
Document.with_error.create(doc_type: :a, external_id: 10)
|
|
35
|
+
Document.with_error.create(doc_type: :b, external_id: 20)
|
|
36
|
+
|
|
37
|
+
get :status
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'when there are no documents' do
|
|
41
|
+
it 'returns 200' do
|
|
42
|
+
expect(response.status).to eq(500)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'returns status json' do
|
|
46
|
+
expect(parsed_response).to eq(expected_response)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe 'count_status' do
|
|
52
|
+
let(:expected_response) do
|
|
53
|
+
{
|
|
54
|
+
'status' => 'error',
|
|
55
|
+
'successes' => {
|
|
56
|
+
'status' => 'error',
|
|
57
|
+
'a' => {
|
|
58
|
+
'count' => 10,
|
|
59
|
+
'status' => 'ok'
|
|
60
|
+
},
|
|
61
|
+
'b' => {
|
|
62
|
+
'count' => 2,
|
|
63
|
+
'status' => 'error'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
let(:a_successes) { 10 }
|
|
70
|
+
let(:b_successes) { 2 }
|
|
71
|
+
|
|
72
|
+
before do
|
|
73
|
+
Document.delete_all
|
|
74
|
+
|
|
75
|
+
a_successes.times do
|
|
76
|
+
Document.with_success.create(doc_type: :a)
|
|
77
|
+
end
|
|
78
|
+
b_successes.times do
|
|
79
|
+
Document.with_success.create(doc_type: :b)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
get :count_status
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'when there are no documents' do
|
|
86
|
+
it 'returns 200' do
|
|
87
|
+
expect(response.status).to eq(500)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'returns status json' do
|
|
91
|
+
expect(parsed_response).to eq(expected_response)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mercy::PeriodParser do
|
|
6
|
+
describe 'yard' do
|
|
7
|
+
describe '.parse' do
|
|
8
|
+
it 'parses string to period' do
|
|
9
|
+
expect(described_class.parse('3days')).to eq(3.days)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#to_seconds' do
|
|
14
|
+
subject(:parser) { described_class.new('30minutes') }
|
|
15
|
+
|
|
16
|
+
it 'parses to period' do
|
|
17
|
+
expect(parser.to_seconds).to eq(30.minutes)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Arstotzka::TypeCast do
|
|
@@ -6,15 +8,14 @@ describe Arstotzka::TypeCast do
|
|
|
6
8
|
let(:dummy_class) { Class.new { include Arstotzka::TypeCast } }
|
|
7
9
|
|
|
8
10
|
describe '#to_period' do
|
|
9
|
-
it_behaves_like 'a method that knows how to parse time', :to_period,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
11
|
+
it_behaves_like 'a method that knows how to parse time', :to_period,
|
|
12
|
+
'3' => 3.seconds,
|
|
13
|
+
'3seconds' => 3.seconds,
|
|
14
|
+
'3minutes' => 3.minutes,
|
|
15
|
+
'3hours' => 3.hours,
|
|
16
|
+
'3days' => 3.days,
|
|
17
|
+
'3months' => 3.months,
|
|
18
|
+
'3years' => 3.years
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
describe '#to_infinity_float' do
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mercy::PeriodParser do
|
|
4
6
|
subject { described_class }
|
|
5
7
|
|
|
6
|
-
it_behaves_like 'a method that knows how to parse time', :parse,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
8
|
+
it_behaves_like 'a method that knows how to parse time', :parse,
|
|
9
|
+
'3' => 3.seconds,
|
|
10
|
+
'3seconds' => 3.seconds,
|
|
11
|
+
'3minutes' => 3.minutes,
|
|
12
|
+
'3hours' => 3.hours,
|
|
13
|
+
'3days' => 3.days,
|
|
14
|
+
'3months' => 3.months,
|
|
15
|
+
'3years' => 3.years
|
|
15
16
|
|
|
16
17
|
context 'when value is already a period' do
|
|
17
18
|
it 'returns the value itself' do
|