[英]How should I include before do in minitest rails3.2?
What is the syntax for writing before do in minitest ? 在minitest中写之前的写法是什么?
I am trying to write a test case using minitest in rails3.2. 我试图在rails3.2中使用minitest编写测试用例。
In development environment, we are loading this data using some background jobs. 在开发环境中,我们使用一些后台作业加载此数据。 so, I have tried to do the same thing in test environment also. 所以,我也尝试在测试环境中做同样的事情。 Before running my test suite, I have to run the task in background and generate vibrancy data and the same is being used in the test suite for asserting. 在运行我的测试套件之前,我必须在后台运行任务并生成活力数据,并在测试套件中使用相同的断言。 but, it's throwing undefined method `before' for CommunityVibrancyTest:Class (NoMethodError) 但是,它为CommunityVibrancyTest抛出未定义的方法`之前':Class(NoMethodError)
require 'test_helper'
Class CommunityVibrancyTest < ActiveSupport::TestCase
before :each do
App::Queue.add(CommunityVibrancyWorker, communities(:private_community).id )
end
test 'to check whether the vibrancy of a private community is handliing share or not' do
private_community = communities(:private_community)
share = shares(:share_for_private_microblog)
stat = share.object
post_vibrancy = stat.aggregated_score_mblog.round(1)
assert_equal post_vibrancy, private_community.community_vibrancies.last.post_vibrancy
end
end
test/unit/community_vibrancy_test.rb:24:in <class:CommunityVibrancyTest>': undefined method
before' for CommunityVibrancyTest:Class (NoMethodError) from test/unit/community_vibrancy_test.rb:4:in `' test / unit / community_vibrancy_test.rb:24:in <class:CommunityVibrancyTest>': undefined method
来自test / unit / community_vibrancy_test.rb的'for CommunityVibrancyTest:Class(NoMethodError)之前的<class:CommunityVibrancyTest>': undefined method
:4:in''
replace before
with setup
before
setup
before
更换
Check detailed documentation here https://api.rubyonrails.org/v5.1.0/classes/ActiveSupport/Testing/SetupAndTeardown.html 查看详细文档https://api.rubyonrails.org/v5.1.0/classes/ActiveSupport/Testing/SetupAndTeardown.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.