在minitest rails3.2中,我该如何包含之前做的准备?

时间:2019-03-25 10:14:13

标签: ruby-on-rails unit-testing ruby-on-rails-3 minitest

minitest之前编写的语法是什么?

我正在尝试在rails3.2中使用minitest编写一个测试用例。

在开发环境中,我们正在使用一些后台作业加载此数据。因此,我也尝试在测试环境中做同样的事情。 在运行测试套件之前,我必须在后台运行任务并生成活力数据,并且在测试套件中使用了该数据进行断言。 但是,它为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:在<class:CommunityVibrancyTest>': undefined method之前,针对CommunityVibrancyTest:Class(NoMethodError)     来自test / unit / community_vibrancy_test.rb:4:in''

1 个答案:

答案 0 :(得分:0)