Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 测试名为mailer的Sidekiq工作_Ruby On Rails_Ruby_Sidekiq - Fatal编程技术网

Ruby on rails 测试名为mailer的Sidekiq工作

Ruby on rails 测试名为mailer的Sidekiq工作,ruby-on-rails,ruby,sidekiq,Ruby On Rails,Ruby,Sidekiq,我正在测试我的Sidekiq作业,并试图找出如何确保它使用正确的参数调用作业中的方法。这是我的实际工作: 工作: 我想构建一个测试,以确保使用正确的参数调用ActivateMailer.send_csv 以下是我目前的情况: 测试: 但这是一个语法错误。有谁能给我一些关于如何正确测试的指导吗?谢谢大家! 来自rspec文档() 需要一条带有参数的消息 鉴于 名为“spec/account_spec.rb”的文件包含: 及 名为“lib/account.rb”的文件包含: 什么时候 我运行rspe

我正在测试我的Sidekiq作业,并试图找出如何确保它使用正确的参数调用作业中的方法。这是我的实际工作:

工作: 我想构建一个测试,以确保使用正确的参数调用ActivateMailer.send_csv

以下是我目前的情况:

测试: 但这是一个语法错误。有谁能给我一些关于如何正确测试的指导吗?谢谢大家!

来自rspec文档()

需要一条带有参数的消息 鉴于 名为“spec/account_spec.rb”的文件包含:

及 名为“lib/account.rb”的文件包含:

什么时候 我运行rspec spec/account\u spec.rb 然后 输出应包含“1个示例,0个故障”

因此,在你的情况下:

CampaignMailer.should_receive(:send_csv).with(<expected_email_arg>, <expected_csv_arg>)
activateMailer.should_receive(:send_csv).with(,)
您还可以添加
和_return()
来测试返回值

RSpec.describe CampaignsExortJob, type: :model do
  subject(:job) { CampaignsExportJob.new }

  describe '#perform' do
    let(:campaign) { create(:campaign) }

    it 'sends the csv email' do
      expect(job).to receive(:CampaignMailer.send_csv)
    end
  end
end
require "account"
require "spec_helper"

describe Account do
  context "when closed" do
    it "logs an account closed message" do
      logger = double("logger")
      account = Account.new logger

      logger.should_receive(:account_closed).with(account)

      account.close
    end
  end
end
Account = Struct.new(:logger) do
  def close
    logger.account_closed(self)
  end
end
CampaignMailer.should_receive(:send_csv).with(<expected_email_arg>, <expected_csv_arg>)