Skip to content

Commit

Permalink
Add #flush and #sync methods to Puma::NullIO (#2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierbellone committed Feb 10, 2021
1 parent 26776c8 commit 7c91d90
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
## 5.2.2 / 2021-02-

* Bugfixes
* Add `#flush` and `#sync` methods to `Puma::NullIO` ([#2553])

## 5.2.1 / 2021-02-05

* Bugfixes
Expand Down
8 changes: 8 additions & 0 deletions lib/puma/null_io.rb
Expand Up @@ -36,6 +36,10 @@ def eof?
true
end

def sync
true
end

def sync=(v)
end

Expand All @@ -44,5 +48,9 @@ def puts(*ary)

def write(*ary)
end

def flush
self
end
end
end
8 changes: 8 additions & 0 deletions test/test_events.rb
Expand Up @@ -97,6 +97,14 @@ def test_log_writes_to_stdout
assert_equal "ready\n", out
end

def test_null_log_does_nothing
out, _ = capture_io do
Puma::Events.null.log("ready")
end

assert_equal "", out
end

def test_write_writes_to_stdout
out, _ = capture_io do
Puma::Events.stdio.write("ready")
Expand Down
8 changes: 8 additions & 0 deletions test/test_null_io.rb
Expand Up @@ -56,4 +56,12 @@ def test_read_with_length_and_buffer
def test_size
assert_equal 0, nio.size
end

def test_sync_returns_true
assert_equal true, nio.sync
end

def test_flush_returns_self
assert_equal nio, nio.flush
end
end

0 comments on commit 7c91d90

Please sign in to comment.