如何用minitest交出params

时间:2017-03-27 08:35:16

标签: ruby-on-rails ruby minitest

我想使用MiniTest将params移交给构造函数,但我不知道该怎么做。

# 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

1 个答案:

答案 0 :(得分:1)

你的意思是什么?

class ItemImageTest < ActiveSupport::TestCase
  def setup
    @avator = Avator.new('image', 'Foo', 15)
  end
end