使用 contains_exactly 匹配器时,我的 rspec 测试返回类似的集合
我正在尝试运行一个测试,其中我实现了 contains_exactly 匹配器。我的测试如下所示: context 'user with multiple roles' do let(:user1) { create(…
如何创建 RSpec 测试来使用所有匹配器测试无效电子邮件数组
我正在尝试对电子邮件验证模式进行测试,为此我创建了一个包含所有无效电子邮件的数组,并尝试使用 not_to all 匹配器来测试它。 context 'when inval…
如何在 rspec 中伪造 Job 方法
我有一个默认情况下停用的Rails model。 Sidekiq 作业在成功后激活它。实施这项工作后,我的所有规格都失败了。我怎样才能“存根”/“伪造”数据库更…
如何在工厂机器人 Rails 的 after_build 中创建关联?
我有一个数据模型,其中 account 对子域具有唯一的验证。 我的大多数其他对象都与 account 对象相关联。 在我的数据模型中,product有一个account_id…
如何测试创建实例的类方法?
我有这样一个类: class BaseService def self.call(*args) new(*args).call end end 我需要测试 #self.call 使用给定参数创建新实例并向其发送 :call…
如何让工厂只为 Rspec 中的所有测试创建一次数据
这是我的代码的一个简化版本: frozen_string_literal: true RSpec.describe MyObject do let!(:my_object) { create(:my_object, name: 'This Name')…
Rspec:执行 mkdir 然后将屏幕截图传递到新目录
我创建了一个 rspec 测试,其中在 it 块内创建了一个目录,并且还截取了测试的各种状态的屏幕截图。 这是我正在测试的一个表单条目,因此 it 块如下所…
Selenium::WebDriver::Error::SessionNotCreatedError:来自 github 中的操作(在 vscod 中效果很好)
2022-03-08 11:21:22 警告 Selenium [弃用] [:driver_path] Selenium::WebDriver::Chrome#driver_path= 已弃用。请改用 Selenium::WebDriver::Chrome:…
尽管有需要的程序,但 Rspec 和 gem 错误
Unfortunately, an unexpected error occurred, and Bundler cannot continue. First, try this link to see if there are any existing issue report…
rspec 参数测试失败
我是 Rails 新手,我正在尝试为控制器方法创建编写规范测试,但我不知道如何传递参数用户来获取方法。 这是项目控制器 def create @project = Project…
为条件 if 语句编写 rspec 测试返回未找到示例
我对 RSPEC 相当陌生,并尝试为以下功能编写测试: private def state_email if CurrentXPX.is?(:Ohio) :oh_update_reminder elsif CurrentXPX.is?(:N…
使用“public_send”更改空 kwargs 的行为
我更新了 Gemfile,因为我的规范失败了。 代码如下: module V1 ## # Pusher job class PusherJob < BaseJob queue_as :default ## # Call V1::Pusher…
有没有正确的方法来使用 is_a?有一个instance_double?
我有现实世界的代码,它执行以下操作: attr_reader :response def initialize(response) @response = response end def success? response.is_a?(Net…
RSpec“全部更改”匹配器
我有一些更新记录的工作,我想要类似的东西: it 'updates each record' do expect { described_class.perform_now }.to(change_all_of{ Record.pluck…
Gemfile 升级后未初始化的常量
我刚刚更新了我的 Gemfile。 一开始我以为问题来自 Zeitwerk (从 2.4.2 到 2.5.4),但我已经降级了它,但仍然有我的规格有问题。我已经确定问题并非…