我的服务层(app / services / article_service.rb)中有ArticleService模块,我想测试这个模块和方法。以下是rspec代码。结果是错误的。我认为原因是测试没有调用ArticleService.create
,但我不知道该怎么做。
module ArticleService
module_function
def create
Article.update(publish: 1)
end
end
require 'rails_helper'
describe ArticleService do
describe '#create' do
it 'update article publish' do
article = create(:article, property: 0)
expect(article.publish).to eq 1
end
end
end