e3a66f5
From fd9aad1ccc736d0ceaa36dfe1732390427354788 Mon Sep 17 00:00:00 2001
e3a66f5
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
e3a66f5
Date: Mon, 8 Jan 2018 13:23:43 +0100
e3a66f5
Subject: [PATCH] Mock Kernel.warn in Ruby 2.5 compatible way.
e3a66f5
e3a66f5
Ruby changed the way Kernel#warn reports the error [1], but mocking the
e3a66f5
method on the class, which is calling it, should be universal [2].
e3a66f5
e3a66f5
[1] https://bugs.ruby-lang.org/issues/12944
e3a66f5
[2] https://www.reddit.com/r/ruby/comments/2nki9q/rspec_how_do_you_mock_or_stub_kernel_methods_like/
e3a66f5
---
e3a66f5
 spec/runner_spec.rb | 6 +++---
e3a66f5
 1 file changed, 3 insertions(+), 3 deletions(-)
e3a66f5
e3a66f5
diff --git a/spec/runner_spec.rb b/spec/runner_spec.rb
e3a66f5
index 825783d..cee6b91 100644
e3a66f5
--- a/spec/runner_spec.rb
e3a66f5
+++ b/spec/runner_spec.rb
e3a66f5
@@ -65,10 +65,10 @@ describe Runner do
e3a66f5
   end
e3a66f5
 
e3a66f5
   it "should warn when require a rack config file" do
e3a66f5
-    STDERR.stub!(:write)
e3a66f5
-    STDERR.should_receive(:write).with(/WARNING:/)
e3a66f5
-
e3a66f5
     runner = Runner.new(%w(start -r config.ru))
e3a66f5
+
e3a66f5
+    runner.should_receive(:warn).with(/WARNING:/)
e3a66f5
+
e3a66f5
     runner.run! rescue nil
e3a66f5
 
e3a66f5
     runner.options[:rackup].should == 'config.ru'
e3a66f5
-- 
e3a66f5
2.15.1
e3a66f5