How to test model's callback method independently?

后端 未结 6 1126
感情败类
感情败类 2021-02-02 07:34

I had a method in a model:

class Article < ActiveRecord::Base
  def do_something
  end
end

I also had a unit test for this method:



        
6条回答
  •  遥遥无期
    2021-02-02 07:38

    describe "#do_something" do
    
     it "gives the article something" do
    
      @article = FactoryGirl.build(:article)
    
       expect(@article).to have_something
    
     @article.save
    end
    
    end
    

提交回复
热议问题