spec/unit/logging_spec.rb in pwwka-0.16.0 vs spec/unit/logging_spec.rb in pwwka-0.16.1
- old
+ new
@@ -23,18 +23,34 @@
describe "#logf" do
let(:logger) { double(Logger) }
before do
@original_logger = Pwwka.configuration.logger
+ @original_log_level = Pwwka.configuration.log_level
Pwwka.configuration.logger = logger
allow(logger).to receive(:info)
allow(logger).to receive(:error)
end
after do
Pwwka.configuration.logger = @original_logger
+ Pwwka.configuration.log_level = @original_log_level
Pwwka.configuration.payload_logging = @original_payload_logging
end
+
+ it "logs a printf-style string at info" do
+ ForLogging.logf("This is %{test} some %{data}", test: "a test of", data: "data and stuff", ignored: :hopefully)
+ expect(logger).to have_received(:info).with("This is a test of some data and stuff")
+ end
+
+ it "logs at a different level if configured to do so" do
+ Pwwka.configuration.log_level = :debug
+ allow(logger).to receive(:debug)
+
+ ForLogging.logf("This is %{test} some %{data}", test: "a test of", data: "data and stuff", ignored: :hopefully)
+ expect(logger).to have_received(:debug).with("This is a test of some data and stuff")
+ end
+
it "logs a printf-style string at info" do
ForLogging.logf("This is %{test} some %{data}", test: "a test of", data: "data and stuff", ignored: :hopefully)
expect(logger).to have_received(:info).with("This is a test of some data and stuff")
end