如何用minitest传递参数
How to hand over params with minitest
我想用 MiniTest 将参数传递给构造函数,但我不知道该怎么做。
# model
class Avator
attr_accessor :image, nickname, age
def initialize(image, nickname, age)
self.image = image
self.nickname = nickname
self.age = age
end
end
# test
class ItemImageTest < ActiveSupport::TestCase
def setup
end
end
你是这个意思吗?
class ItemImageTest < ActiveSupport::TestCase
def setup
@avator = Avator.new('image', 'Foo', 15)
end
end
我想用 MiniTest 将参数传递给构造函数,但我不知道该怎么做。
# model
class Avator
attr_accessor :image, nickname, age
def initialize(image, nickname, age)
self.image = image
self.nickname = nickname
self.age = age
end
end
# test
class ItemImageTest < ActiveSupport::TestCase
def setup
end
end
你是这个意思吗?
class ItemImageTest < ActiveSupport::TestCase
def setup
@avator = Avator.new('image', 'Foo', 15)
end
end