LoginSignup
0
0

More than 5 years have passed since last update.

未経験でrubyの勉強をしています。分からないので教えてください。

Last updated at Posted at 2019-03-09

require 'minitest/autorun'
require './lib/rgb'

class RgbTest < Minitest::Test
def test_to_hex
assert_equal '#000000', to_hex(0, 0, 0)
assert_equal '#ffffff', to_hex(255, 255, 255)
assert_equal '#043c78', to_hex(4, 60, 120)
end

def test_to_ints
assert_equal [0, 0, 0], to_ints('#000000')
assert_equal [255, 255, 255], to_ints('#ffffff')
assert_equal [4, 60, 120], to_ints('#043c78')
end
end

def to_ints(hex)
r = hex[1..2]
g = hex[3..4]
b = hex[5..6]
ints = []
[r, g, b].each do |s|
ints << s.hex
end
ints
end

上記のテストコードとメソッドでパスを通そうとするとエラーが出ます。
打ち間違いがあると思い見返すのですが
なぜ、通らないか分かりません。
どこに間違いがあるか教えてください。
宜しくお願い致します。

ruby2.6.1を使っています。
参考書は「プロを目指す人のためのRuby入門」

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0