appsignal 4.0.5 → 4.0.7

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 (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/build_matrix.yml +2 -1
  6. data/ext/agent.rb +27 -27
  7. data/lib/appsignal/check_in/scheduler.rb +3 -4
  8. data/lib/appsignal/check_in.rb +1 -1
  9. data/lib/appsignal/config.rb +1 -3
  10. data/lib/appsignal/integrations/que.rb +8 -2
  11. data/lib/appsignal/integrations/resque.rb +1 -6
  12. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  13. data/lib/appsignal/version.rb +1 -1
  14. metadata +2 -191
  15. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  16. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  17. data/.github/workflows/ci.yml +0 -3150
  18. data/.github/workflows/create_release_from_tag.yml +0 -62
  19. data/.gitignore +0 -35
  20. data/.gitmodules +0 -3
  21. data/.rspec +0 -4
  22. data/.yardopts +0 -8
  23. data/benchmark.rake +0 -139
  24. data/gemfiles/capistrano2.gemfile +0 -6
  25. data/gemfiles/capistrano3.gemfile +0 -7
  26. data/gemfiles/dry-monitor.gemfile +0 -5
  27. data/gemfiles/grape.gemfile +0 -5
  28. data/gemfiles/hanami-2.0.gemfile +0 -7
  29. data/gemfiles/hanami-2.1.gemfile +0 -7
  30. data/gemfiles/http5.gemfile +0 -5
  31. data/gemfiles/no_dependencies.gemfile +0 -10
  32. data/gemfiles/padrino.gemfile +0 -7
  33. data/gemfiles/psych-3.gemfile +0 -5
  34. data/gemfiles/psych-4.gemfile +0 -5
  35. data/gemfiles/que.gemfile +0 -5
  36. data/gemfiles/rails-6.0.gemfile +0 -10
  37. data/gemfiles/rails-6.1.gemfile +0 -11
  38. data/gemfiles/rails-7.0.gemfile +0 -11
  39. data/gemfiles/rails-7.1.gemfile +0 -11
  40. data/gemfiles/rails-7.2.gemfile +0 -11
  41. data/gemfiles/redis-4.gemfile +0 -5
  42. data/gemfiles/redis-5.gemfile +0 -6
  43. data/gemfiles/resque-2.gemfile +0 -6
  44. data/gemfiles/sequel.gemfile +0 -10
  45. data/gemfiles/sinatra.gemfile +0 -5
  46. data/gemfiles/webmachine1.gemfile +0 -7
  47. data/gemfiles/webmachine2.gemfile +0 -6
  48. data/mono.yml +0 -16
  49. data/spec/.rubocop.yml +0 -7
  50. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  51. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  52. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  53. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
  54. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
  55. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  56. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  57. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  58. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  59. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  60. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  61. data/spec/lib/appsignal/cli_spec.rb +0 -56
  62. data/spec/lib/appsignal/config_spec.rb +0 -1380
  63. data/spec/lib/appsignal/demo_spec.rb +0 -83
  64. data/spec/lib/appsignal/environment_spec.rb +0 -190
  65. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  66. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  67. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  69. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  70. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  71. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  72. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  73. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  74. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  75. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  76. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  77. data/spec/lib/appsignal/extension_spec.rb +0 -178
  78. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  79. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  80. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  81. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  82. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  83. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  84. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  85. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  86. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  87. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  88. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  89. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  90. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  91. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  92. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  93. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  94. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  95. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  96. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  97. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  98. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  99. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  100. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  101. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  102. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  103. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  104. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  105. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  106. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  107. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  108. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  109. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  110. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  111. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  112. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  113. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  114. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  115. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  116. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  117. data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
  118. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  119. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  120. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  121. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  122. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  123. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  124. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  125. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  126. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  127. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  128. data/spec/lib/appsignal/logger_spec.rb +0 -205
  129. data/spec/lib/appsignal/marker_spec.rb +0 -51
  130. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  131. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  132. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  133. data/spec/lib/appsignal/probes_spec.rb +0 -411
  134. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  135. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  136. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  137. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  138. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  139. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  140. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  141. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  142. data/spec/lib/appsignal/rack_spec.rb +0 -243
  143. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  144. data/spec/lib/appsignal/span_spec.rb +0 -141
  145. data/spec/lib/appsignal/system_spec.rb +0 -126
  146. data/spec/lib/appsignal/transaction_spec.rb +0 -2111
  147. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  148. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  149. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  150. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  151. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  152. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  153. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  154. data/spec/lib/appsignal_spec.rb +0 -1919
  155. data/spec/lib/puma/appsignal_spec.rb +0 -334
  156. data/spec/spec_helper.rb +0 -173
  157. data/spec/support/fixtures/generated_config.yml +0 -24
  158. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  159. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  160. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  162. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  163. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  164. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  165. data/spec/support/fixtures/uploaded_file.txt +0 -0
  166. data/spec/support/hanami/hanami_app.rb +0 -29
  167. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  168. data/spec/support/helpers/activejob_helpers.rb +0 -27
  169. data/spec/support/helpers/api_request_helper.rb +0 -20
  170. data/spec/support/helpers/cli_helpers.rb +0 -40
  171. data/spec/support/helpers/config_helpers.rb +0 -66
  172. data/spec/support/helpers/dependency_helper.rb +0 -150
  173. data/spec/support/helpers/directory_helper.rb +0 -27
  174. data/spec/support/helpers/env_helpers.rb +0 -41
  175. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  176. data/spec/support/helpers/example_exception.rb +0 -13
  177. data/spec/support/helpers/example_standard_error.rb +0 -13
  178. data/spec/support/helpers/loader_helper.rb +0 -21
  179. data/spec/support/helpers/log_helpers.rb +0 -36
  180. data/spec/support/helpers/rails_helper.rb +0 -28
  181. data/spec/support/helpers/std_streams_helper.rb +0 -94
  182. data/spec/support/helpers/system_helpers.rb +0 -8
  183. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  184. data/spec/support/helpers/time_helpers.rb +0 -11
  185. data/spec/support/helpers/transaction_helpers.rb +0 -122
  186. data/spec/support/helpers/wait_for_helper.rb +0 -39
  187. data/spec/support/matchers/contains_log.rb +0 -26
  188. data/spec/support/matchers/have_colorized_text.rb +0 -28
  189. data/spec/support/matchers/transaction.rb +0 -200
  190. data/spec/support/mocks/appsignal_mock.rb +0 -18
  191. data/spec/support/mocks/dummy_app.rb +0 -20
  192. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  193. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  194. data/spec/support/mocks/hash_like.rb +0 -10
  195. data/spec/support/mocks/mock_probe.rb +0 -13
  196. data/spec/support/mocks/puma_mock.rb +0 -43
  197. data/spec/support/shared_examples/instrument.rb +0 -48
  198. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  199. data/spec/support/stubs/delayed_job.rb +0 -0
  200. data/spec/support/stubs/sidekiq/api.rb +0 -4
  201. data/spec/support/testing.rb +0 -194
  202. data/support/bundler_wrapper +0 -12
  203. data/support/install_deps +0 -33
@@ -1,153 +0,0 @@
1
- describe Appsignal::Utils::IntegrationLogger do
2
- let(:formatter) { nil }
3
- let(:logger) do
4
- Appsignal::Utils::IntegrationMemoryLogger.new.tap do |l|
5
- l.formatter = formatter if formatter
6
- end
7
- end
8
-
9
- describe "#add" do
10
- it "adds a log message with the severity" do
11
- logger.add(:DEBUG, "debug message")
12
- logger.add(:INFO, "info message")
13
- logger.add(:WARN, "warn message")
14
- logger.add(:ERROR, "error message")
15
- logger.add(:FATAL, "fatal message")
16
- logger.add(:UNKNOWN, "unknown message")
17
-
18
- expect(logger.messages[:DEBUG]).to eq(["debug message"])
19
- expect(logger.messages[:INFO]).to eq(["info message"])
20
- expect(logger.messages[:WARN]).to eq(["warn message"])
21
- expect(logger.messages[:ERROR]).to eq(["error message"])
22
- expect(logger.messages[:FATAL]).to eq(["fatal message"])
23
- expect(logger.messages[:UNKNOWN]).to eq(["unknown message"])
24
- end
25
-
26
- context "without formatter" do
27
- it "logs in the default format" do
28
- logger.add(:DEBUG, "debug message")
29
- expect(logger.messages[:DEBUG]).to eq(["debug message"])
30
- end
31
- end
32
-
33
- context "with formatter" do
34
- let(:formatter) do
35
- proc do |severity, _datetime, _progname, msg|
36
- "[TIME (process) #PID][#{severity}] #{msg}\n"
37
- end
38
- end
39
-
40
- it "formats the logs using the formatter" do
41
- logger.add(:DEBUG, "debug message")
42
- expect(logger.messages[:DEBUG]).to eq(["[TIME (process) #PID][DEBUG] debug message\n"])
43
- end
44
- end
45
- end
46
-
47
- describe "#debug" do
48
- it "adds a log message with the debug severity" do
49
- logger.debug("debug message")
50
-
51
- expect(logger.messages[:DEBUG]).to eq(["debug message"])
52
- end
53
- end
54
-
55
- describe "#info" do
56
- it "adds a log message with the info severity" do
57
- logger.info("info message")
58
-
59
- expect(logger.messages[:INFO]).to eq(["info message"])
60
- end
61
- end
62
-
63
- describe "#warn" do
64
- it "adds a log message with the warn severity" do
65
- logger.warn("warn message")
66
-
67
- expect(logger.messages[:WARN]).to eq(["warn message"])
68
- end
69
- end
70
-
71
- describe "#error" do
72
- it "adds a log message with the error severity" do
73
- logger.error("error message")
74
-
75
- expect(logger.messages[:ERROR]).to eq(["error message"])
76
- end
77
- end
78
-
79
- describe "#fatal" do
80
- it "adds a log message with the fatal severity" do
81
- logger.fatal("fatal message")
82
-
83
- expect(logger.messages[:FATAL]).to eq(["fatal message"])
84
- end
85
- end
86
-
87
- describe "#unknown" do
88
- it "adds a log message with the unknown severity" do
89
- logger.unknown("unknown message")
90
-
91
- expect(logger.messages[:UNKNOWN]).to eq(["unknown message"])
92
- end
93
- end
94
-
95
- describe "#clear" do
96
- it "clears all log messages" do
97
- logger.add(:DEBUG, "debug message")
98
- logger.add(:INFO, "info message")
99
- logger.add(:WARN, "warn message")
100
- logger.add(:ERROR, "error message")
101
- logger.add(:FATAL, "fatal message")
102
- logger.add(:UNKNOWN, "unknown message")
103
- logger.clear
104
-
105
- expect(logger.messages).to be_empty
106
- end
107
- end
108
-
109
- describe "#messages_for_level" do
110
- it "returns only log messages for level and higher" do
111
- logger.add(:DEBUG, "debug message")
112
- logger.add(:INFO, "info message")
113
- logger.add(:WARN, "warn message")
114
- logger.add(:ERROR, "error message")
115
- logger.add(:FATAL, "fatal message")
116
- logger.add(:UNKNOWN, "unknown message")
117
-
118
- expect(logger.messages_for_level(Logger::DEBUG)).to eq([
119
- "debug message",
120
- "info message",
121
- "warn message",
122
- "error message",
123
- "fatal message",
124
- "unknown message"
125
- ])
126
- expect(logger.messages_for_level(Logger::INFO)).to eq([
127
- "info message",
128
- "warn message",
129
- "error message",
130
- "fatal message",
131
- "unknown message"
132
- ])
133
- expect(logger.messages_for_level(Logger::WARN)).to eq([
134
- "warn message",
135
- "error message",
136
- "fatal message",
137
- "unknown message"
138
- ])
139
- expect(logger.messages_for_level(Logger::ERROR)).to eq([
140
- "error message",
141
- "fatal message",
142
- "unknown message"
143
- ])
144
- expect(logger.messages_for_level(Logger::FATAL)).to eq([
145
- "fatal message",
146
- "unknown message"
147
- ])
148
- expect(logger.messages_for_level(Logger::UNKNOWN)).to eq([
149
- "unknown message"
150
- ])
151
- end
152
- end
153
- end
@@ -1,44 +0,0 @@
1
- describe Appsignal::Utils::JSON do
2
- describe ".generate" do
3
- subject { Appsignal::Utils::JSON.generate(body) }
4
-
5
- context "with a valid body" do
6
- let(:body) do
7
- {
8
- "the" => "payload",
9
- 1 => true,
10
- nil => "test",
11
- :foo => [1, 2, "three"],
12
- "bar" => nil,
13
- "baz" => { "foo" => "bar" }
14
- }
15
- end
16
-
17
- it "returns a JSON string" do
18
- is_expected.to eq %({"the":"payload","1":true,"":"test",) +
19
- %("foo":[1,2,"three"],"bar":null,"baz":{"foo":"bar"}})
20
- end
21
- end
22
-
23
- context "with a body that contains strings with invalid UTF-8 content" do
24
- let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
25
- let(:body) do
26
- {
27
- "field_one" => [0x61, 0x61].pack("c*"),
28
- :field_two => string_with_invalid_utf8,
29
- "field_three" => [
30
- "one", string_with_invalid_utf8
31
- ],
32
- "field_four" => {
33
- "one" => string_with_invalid_utf8
34
- }
35
- }
36
- end
37
-
38
- it "returns a JSON string with invalid UTF-8 content" do
39
- is_expected.to eq %({"field_one":"aa","field_two":"aa�",) +
40
- %("field_three":["one","aa�"],"field_four":{"one":"aa�"}})
41
- end
42
- end
43
- end
44
- end
@@ -1,192 +0,0 @@
1
- describe Appsignal::Utils::QueryParamsSanitizer do
2
- describe ".sanitize" do
3
- context "when only_top_level = true" do
4
- subject { described_class.sanitize(value, true) }
5
-
6
- context "when value is a hash" do
7
- let(:value) { { "foo" => "bar" } }
8
-
9
- it "should only return the first level of the object" do
10
- expect(subject).to eq("foo" => "?")
11
- end
12
-
13
- it "should not modify source value" do
14
- subject
15
- expect(value).to eq("foo" => "bar")
16
- end
17
- end
18
-
19
- context "when value is a nested hash" do
20
- let(:value) { { "foo" => { "bar" => "baz" } } }
21
-
22
- it "should only return the first level of the object" do
23
- expect(subject).to eq("foo" => "?")
24
- end
25
-
26
- it "should not modify source value" do
27
- subject
28
- expect(value).to eq("foo" => { "bar" => "baz" })
29
- end
30
- end
31
-
32
- context "when value is an array of hashes" do
33
- let(:value) { ["foo" => "bar"] }
34
-
35
- it "should sanitize all hash values with a questionmark" do
36
- expect(subject).to eq(["foo" => "?"])
37
- end
38
-
39
- it "should not modify source value" do
40
- subject
41
- expect(value).to eq(["foo" => "bar"])
42
- end
43
- end
44
-
45
- context "when value is an array" do
46
- let(:value) { %w[foo bar] }
47
-
48
- it "sanitizes all array values" do
49
- expect(subject).to eq(["?"])
50
- end
51
-
52
- it "should not modify source value" do
53
- subject
54
- expect(value).to eq(%w[foo bar])
55
- end
56
- end
57
-
58
- context "when value is a mixed array" do
59
- let(:value) { [nil, "foo", "bar"] }
60
-
61
- it "should sanitize all array values with a single questionmark" do
62
- expect(subject).to eq(["?"])
63
- end
64
- end
65
-
66
- context "when value is a string" do
67
- let(:value) { "foo" }
68
-
69
- it "should sanitize all hash values with a questionmark" do
70
- expect(subject).to eq("?")
71
- end
72
- end
73
- end
74
-
75
- context "when only_top_level = false" do
76
- subject { described_class.sanitize(value, false) }
77
-
78
- context "when value is a hash" do
79
- let(:value) { { "foo" => "bar" } }
80
-
81
- it "should sanitize all hash values with a questionmark" do
82
- expect(subject).to eq("foo" => "?")
83
- end
84
-
85
- it "should not modify source value" do
86
- subject
87
- expect(value).to eq("foo" => "bar")
88
- end
89
- end
90
-
91
- context "when value is a nested hash" do
92
- let(:value) { { "foo" => { "bar" => "baz" } } }
93
-
94
- it "should replaces values" do
95
- expect(subject).to eq("foo" => { "bar" => "?" })
96
- end
97
-
98
- it "should not modify source value" do
99
- subject
100
- expect(value).to eq("foo" => { "bar" => "baz" })
101
- end
102
- end
103
-
104
- context "when value is an array of hashes" do
105
- let(:value) { ["foo" => "bar"] }
106
-
107
- it "should sanitize all hash values with a questionmark" do
108
- expect(subject).to eq(["foo" => "?"])
109
- end
110
-
111
- it "should not modify source value" do
112
- subject
113
- expect(value).to eq(["foo" => "bar"])
114
- end
115
- end
116
-
117
- context "when value is an array" do
118
- let(:value) { %w[foo bar] }
119
-
120
- it "should sanitize all hash values with a single question mark" do
121
- expect(subject).to eq(["?"])
122
- end
123
- end
124
-
125
- context "when value is a mixed array" do
126
- let(:value) { [nil, "foo", "bar"] }
127
-
128
- it "should sanitize all hash values with a single question mark" do
129
- expect(subject).to eq(["?"])
130
- end
131
- end
132
-
133
- context "when value is a string" do
134
- let(:value) { "bar" }
135
-
136
- it "should sanitize all hash values with a questionmark" do
137
- expect(subject).to eq("?")
138
- end
139
- end
140
- end
141
- end
142
-
143
- describe "key_sanitizer option" do
144
- context "without key_sanitizer" do
145
- subject { described_class.sanitize(value) }
146
-
147
- context "when dots are in the key" do
148
- let(:value) { { "foo.bar" => "bar" } }
149
-
150
- it "should not sanitize the key" do
151
- expect(subject).to eql("foo.bar" => "?")
152
- end
153
- end
154
-
155
- context "when key is a symbol" do
156
- let(:value) { { :ismaster => "bar" } }
157
-
158
- it "should sanitize the key" do
159
- expect(subject).to eql(:ismaster => "?")
160
- end
161
- end
162
- end
163
-
164
- context "with mongodb key_sanitizer" do
165
- subject { described_class.sanitize(value, false, :mongodb) }
166
-
167
- context "when no dots are in the key" do
168
- let(:value) { { "foo" => "bar" } }
169
-
170
- it "should not sanitize the key" do
171
- expect(subject).to eql("foo" => "?")
172
- end
173
- end
174
-
175
- context "when dots are in the key" do
176
- let(:value) { { "foo.bar" => "bar" } }
177
-
178
- it "should sanitize the key" do
179
- expect(subject).to eql("foo.?" => "?")
180
- end
181
- end
182
-
183
- context "when key is a symbol" do
184
- let(:value) { { :ismaster => "bar" } }
185
-
186
- it "should sanitize the key" do
187
- expect(subject).to eql("ismaster" => "?")
188
- end
189
- end
190
- end
191
- end
192
- end