lhc 12.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 +7 -0
- data/.gitignore +37 -0
- data/.rubocop.localch.yml +325 -0
- data/.rubocop.yml +61 -0
- data/.ruby-version +1 -0
- data/Gemfile +13 -0
- data/Gemfile.activesupport4 +4 -0
- data/Gemfile.activesupport5 +4 -0
- data/Gemfile.activesupport6 +4 -0
- data/LICENSE +674 -0
- data/README.md +984 -0
- data/Rakefile +25 -0
- data/cider-ci.yml +6 -0
- data/cider-ci/bin/bundle +51 -0
- data/cider-ci/bin/ruby_install +8 -0
- data/cider-ci/bin/ruby_version +25 -0
- data/cider-ci/jobs/rspec-activesupport-4.yml +28 -0
- data/cider-ci/jobs/rspec-activesupport-5.yml +27 -0
- data/cider-ci/jobs/rspec-activesupport-6.yml +28 -0
- data/cider-ci/jobs/rubocop.yml +18 -0
- data/cider-ci/task_components/bundle.yml +22 -0
- data/cider-ci/task_components/rspec.yml +36 -0
- data/cider-ci/task_components/rubocop.yml +29 -0
- data/cider-ci/task_components/ruby.yml +15 -0
- data/friday.yml +3 -0
- data/lhc.gemspec +39 -0
- data/lib/core_ext/hash/deep_transform_values.rb +48 -0
- data/lib/lhc.rb +136 -0
- data/lib/lhc/concerns/lhc/basic_methods_concern.rb +42 -0
- data/lib/lhc/concerns/lhc/configuration_concern.rb +20 -0
- data/lib/lhc/concerns/lhc/fix_invalid_encoding_concern.rb +42 -0
- data/lib/lhc/concerns/lhc/formats_concern.rb +25 -0
- data/lib/lhc/concerns/lhc/request/user_agent_concern.rb +25 -0
- data/lib/lhc/config.rb +47 -0
- data/lib/lhc/endpoint.rb +119 -0
- data/lib/lhc/error.rb +80 -0
- data/lib/lhc/errors/client_error.rb +73 -0
- data/lib/lhc/errors/parser_error.rb +4 -0
- data/lib/lhc/errors/server_error.rb +28 -0
- data/lib/lhc/errors/timeout.rb +4 -0
- data/lib/lhc/errors/unknown_error.rb +4 -0
- data/lib/lhc/format.rb +18 -0
- data/lib/lhc/formats.rb +8 -0
- data/lib/lhc/formats/form.rb +45 -0
- data/lib/lhc/formats/json.rb +55 -0
- data/lib/lhc/formats/multipart.rb +45 -0
- data/lib/lhc/formats/plain.rb +42 -0
- data/lib/lhc/interceptor.rb +32 -0
- data/lib/lhc/interceptors.rb +26 -0
- data/lib/lhc/interceptors/auth.rb +98 -0
- data/lib/lhc/interceptors/caching.rb +127 -0
- data/lib/lhc/interceptors/default_timeout.rb +16 -0
- data/lib/lhc/interceptors/logging.rb +37 -0
- data/lib/lhc/interceptors/monitoring.rb +63 -0
- data/lib/lhc/interceptors/prometheus.rb +51 -0
- data/lib/lhc/interceptors/retry.rb +41 -0
- data/lib/lhc/interceptors/rollbar.rb +36 -0
- data/lib/lhc/interceptors/throttle.rb +81 -0
- data/lib/lhc/interceptors/zipkin.rb +110 -0
- data/lib/lhc/railtie.rb +10 -0
- data/lib/lhc/request.rb +157 -0
- data/lib/lhc/response.rb +60 -0
- data/lib/lhc/response/data.rb +28 -0
- data/lib/lhc/response/data/base.rb +22 -0
- data/lib/lhc/response/data/collection.rb +16 -0
- data/lib/lhc/response/data/item.rb +29 -0
- data/lib/lhc/rspec.rb +12 -0
- data/lib/lhc/test/cache_helper.rb +3 -0
- data/lib/lhc/version.rb +5 -0
- data/script/ci/build.sh +19 -0
- data/spec/basic_methods/delete_spec.rb +34 -0
- data/spec/basic_methods/get_spec.rb +49 -0
- data/spec/basic_methods/post_spec.rb +42 -0
- data/spec/basic_methods/put_spec.rb +48 -0
- data/spec/basic_methods/request_spec.rb +19 -0
- data/spec/basic_methods/request_without_rails_spec.rb +29 -0
- data/spec/config/endpoints_spec.rb +63 -0
- data/spec/config/placeholders_spec.rb +32 -0
- data/spec/core_ext/hash/deep_transform_values_spec.rb +24 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -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/config.ru +6 -0
- data/spec/dummy/config/application.rb +16 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +36 -0
- data/spec/dummy/config/environments/production.rb +77 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/assets.rb +10 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -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/session_store.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +11 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -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/favicon.ico +0 -0
- data/spec/endpoint/compile_spec.rb +35 -0
- data/spec/endpoint/match_spec.rb +41 -0
- data/spec/endpoint/placeholders_spec.rb +30 -0
- data/spec/endpoint/remove_interpolated_params_spec.rb +17 -0
- data/spec/endpoint/values_as_params_spec.rb +31 -0
- data/spec/error/dup_spec.rb +12 -0
- data/spec/error/find_spec.rb +57 -0
- data/spec/error/response_spec.rb +17 -0
- data/spec/error/timeout_spec.rb +14 -0
- data/spec/error/to_s_spec.rb +80 -0
- data/spec/formats/form_spec.rb +27 -0
- data/spec/formats/json_spec.rb +66 -0
- data/spec/formats/multipart_spec.rb +26 -0
- data/spec/formats/plain_spec.rb +29 -0
- data/spec/interceptors/after_request_spec.rb +20 -0
- data/spec/interceptors/after_response_spec.rb +39 -0
- data/spec/interceptors/auth/basic_auth_spec.rb +17 -0
- data/spec/interceptors/auth/bearer_spec.rb +19 -0
- data/spec/interceptors/auth/reauthentication_configuration_spec.rb +61 -0
- data/spec/interceptors/auth/reauthentication_spec.rb +44 -0
- data/spec/interceptors/before_request_spec.rb +21 -0
- data/spec/interceptors/before_response_spec.rb +20 -0
- data/spec/interceptors/caching/hydra_spec.rb +26 -0
- data/spec/interceptors/caching/main_spec.rb +73 -0
- data/spec/interceptors/caching/methods_spec.rb +42 -0
- data/spec/interceptors/caching/options_spec.rb +89 -0
- data/spec/interceptors/caching/parameters_spec.rb +24 -0
- data/spec/interceptors/caching/response_status_spec.rb +29 -0
- data/spec/interceptors/caching/to_cache_spec.rb +16 -0
- data/spec/interceptors/default_interceptors_spec.rb +15 -0
- data/spec/interceptors/default_timeout/main_spec.rb +34 -0
- data/spec/interceptors/define_spec.rb +29 -0
- data/spec/interceptors/dup_spec.rb +19 -0
- data/spec/interceptors/logging/main_spec.rb +37 -0
- data/spec/interceptors/monitoring/main_spec.rb +97 -0
- data/spec/interceptors/prometheus_spec.rb +54 -0
- data/spec/interceptors/response_competition_spec.rb +41 -0
- data/spec/interceptors/retry/main_spec.rb +73 -0
- data/spec/interceptors/return_response_spec.rb +38 -0
- data/spec/interceptors/rollbar/invalid_encoding_spec.rb +43 -0
- data/spec/interceptors/rollbar/main_spec.rb +57 -0
- data/spec/interceptors/throttle/main_spec.rb +106 -0
- data/spec/interceptors/throttle/reset_track_spec.rb +53 -0
- data/spec/interceptors/zipkin/distributed_tracing_spec.rb +135 -0
- data/spec/rails_helper.rb +6 -0
- data/spec/request/body_spec.rb +39 -0
- data/spec/request/encoding_spec.rb +37 -0
- data/spec/request/error_handling_spec.rb +88 -0
- data/spec/request/headers_spec.rb +12 -0
- data/spec/request/ignore_errors_spec.rb +73 -0
- data/spec/request/option_dup_spec.rb +13 -0
- data/spec/request/parallel_requests_spec.rb +59 -0
- data/spec/request/params_encoding_spec.rb +26 -0
- data/spec/request/request_without_rails_spec.rb +15 -0
- data/spec/request/url_patterns_spec.rb +54 -0
- data/spec/request/user_agent_spec.rb +26 -0
- data/spec/request/user_agent_without_rails_spec.rb +27 -0
- data/spec/response/body_spec.rb +16 -0
- data/spec/response/code_spec.rb +16 -0
- data/spec/response/data_accessor_spec.rb +29 -0
- data/spec/response/data_spec.rb +61 -0
- data/spec/response/effective_url_spec.rb +16 -0
- data/spec/response/headers_spec.rb +18 -0
- data/spec/response/options_spec.rb +18 -0
- data/spec/response/success_spec.rb +13 -0
- data/spec/response/time_spec.rb +21 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/fixtures/json/feedback.json +11 -0
- data/spec/support/fixtures/json/feedbacks.json +164 -0
- data/spec/support/fixtures/json/localina_content_ad.json +23 -0
- data/spec/support/load_json.rb +5 -0
- data/spec/support/reset_config.rb +7 -0
- data/spec/support/zipkin_mock.rb +113 -0
- data/spec/timeouts/no_signal_spec.rb +13 -0
- data/spec/timeouts/timings_spec.rb +55 -0
- metadata +534 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'post' do
|
|
7
|
+
let(:feedback) do
|
|
8
|
+
{
|
|
9
|
+
recommended: true,
|
|
10
|
+
source_id: 'aaa',
|
|
11
|
+
content_ad_id: '1z-5r1fkaj'
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before(:each) do
|
|
16
|
+
stub_request(:post, "http://datastore/v2/feedbacks")
|
|
17
|
+
.with(body: feedback.to_json)
|
|
18
|
+
.to_return(status: 200, body: feedback.to_json, headers: { 'Content-Encoding' => 'UTF-8' })
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'does a post request when providing a complete url' do
|
|
22
|
+
LHC.post('http://datastore/v2/feedbacks', body: feedback)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'does a post request when providing the name of a configured endpoint' do
|
|
26
|
+
url = 'http://{+datastore}/v2/feedbacks'
|
|
27
|
+
options = { params: { datastore: 'datastore' } }
|
|
28
|
+
LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
|
|
29
|
+
LHC.post(:feedbacks, body: feedback)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'makes response data available in a rails way' do
|
|
33
|
+
response = LHC.post('http://datastore/v2/feedbacks', body: feedback)
|
|
34
|
+
expect(response.data.source_id).to eq 'aaa'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'provides response headers' do
|
|
38
|
+
response = LHC.post('http://datastore/v2/feedbacks', body: feedback)
|
|
39
|
+
expect(response.headers).to be_present
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'post' do
|
|
7
|
+
let(:feedback) do
|
|
8
|
+
{
|
|
9
|
+
recommended: false,
|
|
10
|
+
source_id: 'aaa',
|
|
11
|
+
content_ad_id: '1z-5r1fkaj'
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:change) do
|
|
16
|
+
{
|
|
17
|
+
recommended: false
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
before(:each) do
|
|
22
|
+
stub_request(:put, "http://datastore/v2/feedbacks")
|
|
23
|
+
.with(body: change.to_json)
|
|
24
|
+
.to_return(status: 200, body: feedback.merge(change).to_json, headers: { 'Content-Encoding' => 'UTF-8' })
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'does a post request when providing a complete url' do
|
|
28
|
+
LHC.put('http://datastore/v2/feedbacks', body: change)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'does a post request when providing the name of a configured endpoint' do
|
|
32
|
+
url = 'http://{+datastore}/v2/feedbacks'
|
|
33
|
+
options = { params: { datastore: 'datastore' } }
|
|
34
|
+
LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
|
|
35
|
+
LHC.put(:feedbacks, body: change)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'makes response data available in a rails way' do
|
|
39
|
+
response = LHC.put('http://datastore/v2/feedbacks', body: change)
|
|
40
|
+
expect(response.data.recommended).to eq false
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'provides response headers' do
|
|
44
|
+
response = LHC.put('http://datastore/v2/feedbacks', body: change)
|
|
45
|
+
expect(response.headers).to be_present
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'request' do
|
|
7
|
+
let(:total) { 99 }
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
stub_request(:get, "http://datastore/v2/feedbacks?has_reviews=true")
|
|
11
|
+
.to_return(status: 200, body: { total: total }.to_json, headers: { 'Content-Encoding' => 'UTF-8' })
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'does a request returning a response' do
|
|
15
|
+
response = LHC.request(url: 'http://datastore/v2/feedbacks', params: { has_reviews: true }, method: :get)
|
|
16
|
+
expect(response.data.total).to eq total
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'GET' do
|
|
7
|
+
before do
|
|
8
|
+
stub_request(:get, "http://datastore/v2/feedbacks").to_return(status: 200, body: "{}")
|
|
9
|
+
end
|
|
10
|
+
it "is able to call .request without LHC raising NoMethodError: undefined method `blank?' for nil:NilClass when calling it outside of the rails context" do
|
|
11
|
+
expect { LHC.request(url: "http://datastore/v2/feedbacks", method: :get) }.not_to raise_error
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'POST' do
|
|
16
|
+
before do
|
|
17
|
+
stub_request(:post, "http://datastore/v2/feedbacks").to_return(status: 200, body: "{}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "is able to call .request without LHC raising NoMethodError: undefined method `deep_symbolize_keys' for {}:Hash" do
|
|
21
|
+
options = {
|
|
22
|
+
url: "http://datastore/v2/feedbacks",
|
|
23
|
+
method: :post,
|
|
24
|
+
body: {}
|
|
25
|
+
}
|
|
26
|
+
expect { LHC.request(options) }.not_to raise_error
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'configured endpoints' do
|
|
7
|
+
let(:url) { 'http://analytics/track/{entity_id}/w/{type}' }
|
|
8
|
+
|
|
9
|
+
let(:options) do
|
|
10
|
+
{
|
|
11
|
+
params: { env: 'PROD' },
|
|
12
|
+
followlocation: false
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
before(:each) do
|
|
17
|
+
LHC.configure do |c|
|
|
18
|
+
c.endpoint(:kpi_tracker, url, options)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'configures urls to be able to access them by name later' do
|
|
23
|
+
expect(LHC.config.endpoints[:kpi_tracker].url).to eq url
|
|
24
|
+
expect(LHC.config.endpoints[:kpi_tracker].options).to eq options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'compile url' do
|
|
28
|
+
stub_request(:get, 'http://analytics/track/123/w/request?env=PROD')
|
|
29
|
+
response = LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request' })
|
|
30
|
+
expect(response.request.options[:followlocation]).to eq false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'gets overwritten by explicit request options' do
|
|
34
|
+
stub_request(:get, 'http://analytics/track/123/w/request?env=STG')
|
|
35
|
+
LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request', env: 'STG' })
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'raises in case of claching endpoint names' do
|
|
39
|
+
expect(lambda {
|
|
40
|
+
LHC.config.endpoint(:kpi_tracker, 'http://kpi-tracker')
|
|
41
|
+
}).to raise_error 'Endpoint already exists for that name'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'enforces endpoint name to be a symbol' do
|
|
45
|
+
LHC.configure { |c| c.endpoint('datastore', 'http://datastore') }
|
|
46
|
+
expect(LHC.config.endpoints[:datastore].url).to eq 'http://datastore'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'configured enpoints with default params' do
|
|
51
|
+
before(:each) do
|
|
52
|
+
LHC.config.endpoint(:telemarketers, 'http://datastore/v2/spamnumbers?order_by=-user_frequency&swiss_number=true&offset=0&limit=:limit', params: { limit: 200 })
|
|
53
|
+
stub_request(:get, 'http://datastore/v2/spamnumbers?limit=200&offset=0&order_by=-user_frequency&swiss_number=true')
|
|
54
|
+
.to_return(status: 200)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'is possible to call them multiple times with default params' do
|
|
58
|
+
LHC.get(:telemarketers)
|
|
59
|
+
LHC.get(:telemarketers)
|
|
60
|
+
LHC.get(:telemarketers)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe LHC do
|
|
6
|
+
context 'configuration of placeholders' do
|
|
7
|
+
it 'uses values for placeholders defined globally' do
|
|
8
|
+
LHC.configure { |c| c.placeholder(:datastore, 'http://datastore/v2') }
|
|
9
|
+
stub_request(:get, "http://datastore/v2/feedbacks")
|
|
10
|
+
LHC.get('{+datastore}/feedbacks')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'uses explicit values first' do
|
|
14
|
+
LHC.configure { |c| c.placeholder(:campaign_id, '123') }
|
|
15
|
+
stub_request(:get, 'http://datastore/v2/campaign/456/feedbacks')
|
|
16
|
+
url = 'http://datastore/v2/campaign/{campaign_id}/feedbacks'
|
|
17
|
+
LHC.get(url, params: { campaign_id: '456' })
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'raises in case of claching placeholder name' do
|
|
21
|
+
LHC.configure { |c| c.placeholder(:datastore, 'http://datastore') }
|
|
22
|
+
expect(lambda {
|
|
23
|
+
LHC.config.placeholder(:datastore, 'http://datastore')
|
|
24
|
+
}).to raise_error 'Placeholder already exists for that name'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'enforces placeholder name to be a symbol' do
|
|
28
|
+
LHC.configure { |c| c.placeholder('datatore', 'http://datastore') }
|
|
29
|
+
expect(LHC.config.placeholders[:datatore]).to eq 'http://datastore'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
require 'core_ext/hash/deep_transform_values'
|
|
5
|
+
|
|
6
|
+
describe Hash do
|
|
7
|
+
subject do
|
|
8
|
+
{
|
|
9
|
+
'key' => 'value',
|
|
10
|
+
'key2' => { 'key' => 'value', key2: 'value' }
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:expected_result) do
|
|
15
|
+
{
|
|
16
|
+
'key' => 'VALUE',
|
|
17
|
+
'key2' => { 'key' => 'VALUE', key2: 'VALUE' }
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'applies upcase to all values' do
|
|
22
|
+
expect(subject.deep_transform_values { |value| value.upcase }).to eq(expected_result)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
5
|
+
|
|
6
|
+
require File.expand_path('../config/application', __FILE__)
|
|
7
|
+
|
|
8
|
+
Rails.application.load_tasks
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path('../boot', __FILE__)
|
|
4
|
+
|
|
5
|
+
require "action_controller/railtie"
|
|
6
|
+
require "action_mailer/railtie"
|
|
7
|
+
require "sprockets/railtie"
|
|
8
|
+
require "rails/test_unit/railtie"
|
|
9
|
+
|
|
10
|
+
Bundler.require(*Rails.groups)
|
|
11
|
+
require "lhc"
|
|
12
|
+
|
|
13
|
+
module Dummy
|
|
14
|
+
class Application < Rails::Application
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Set up gems listed in the Gemfile.
|
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|