回答編集履歴
2
追記
test
CHANGED
@@ -1 +1,49 @@
|
|
1
1
|
[`$stdin`](https://docs.ruby-lang.org/ja/latest/method/Kernel/v/=3e.html)を[StringIO](https://docs.ruby-lang.org/ja/latest/class/StringIO.html)で書き換えるとよいと思います。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
----
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
|
11
|
+
require "minitest/autorun"
|
12
|
+
|
13
|
+
require "stringio"
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
describe "Test" do
|
18
|
+
|
19
|
+
describe "4 5 7" do
|
20
|
+
|
21
|
+
$stdin = StringIO.new("4 5 7\n")
|
22
|
+
|
23
|
+
stdout = $stdout
|
24
|
+
|
25
|
+
$stdout = StringIO.new
|
26
|
+
|
27
|
+
load "./target.rb"
|
28
|
+
|
29
|
+
output = $stdout.string
|
30
|
+
|
31
|
+
$stdout = stdout
|
32
|
+
|
33
|
+
it "must Number" do
|
34
|
+
|
35
|
+
_(output.lines[-1]).must_match /^\d+\n?$/
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must 2" do
|
40
|
+
|
41
|
+
_(output.lines[-1].to_i).must_equal 2
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
```
|
1
変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[`$std
|
1
|
+
[`$stdin`](https://docs.ruby-lang.org/ja/latest/method/Kernel/v/=3e.html)を[StringIO](https://docs.ruby-lang.org/ja/latest/class/StringIO.html)で書き換えるとよいと思います。
|