質問編集履歴
1
文の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,9 +1,27 @@
|
|
1
|
-
convert_lengthを使って、メートルをインチに変換しようとし
|
1
|
+
convert_lengthを使って、メートルをインチに変換しようと考え、libディレクトリにconvert_length.rbというファイルを作成し、
|
2
2
|
```Ruby
|
3
|
-
convert_length(
|
3
|
+
def convert_length(length, unit_from, unit_to)
|
4
|
+
39.37
|
5
|
+
end
|
4
6
|
```
|
5
|
-
↑
|
7
|
+
↑このようなコードを書きました。
|
6
8
|
|
7
|
-
エラー内容は、undefind method 'convert_length' for main:Object (NoMethodError)と表示されます。
|
8
9
|
|
10
|
+
|
11
|
+
次に、testディレクトリにconvert_length_test.rbというファイルを作り、そこに
|
12
|
+
```Ruby
|
13
|
+
require 'minitest/autorun'
|
14
|
+
require '../lib/convert_length'
|
15
|
+
|
16
|
+
class ConvertLengthTest < Minitest::Test
|
17
|
+
def test_convert_length
|
18
|
+
assert_equal 39.37, convert_length(1, 'm', 'in')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
```
|
22
|
+
↑このようなコードを書きました。
|
23
|
+
これを実行すると、エラーになってしまいます。
|
24
|
+
|
25
|
+
エラー内容は、'require': cannot load such file -- ../lib/convert/length(LoadError) と表示されます。
|
26
|
+
|
9
27
|
何処が間違っているでしょうか?
|