0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

rspec moduleのテスト

Posted at

先日、rspecでテストを書いていて、moduleのテストって一体どうやるんだ?と思い調べていると
いろいろな情報が混在していたので忘備録として書いておきます。

結論としてはかなり単純で、
擬似クラスを作成して、それにmoduleをincludeするだけでした。

# frozen_string_literal: true
require 'rails_helper'

RSpec.describe Hoge do
  let(:dummy_class) { Class.new { include FooBarModule } }

  it 'can register data in A tables' do
    dummy_class.method
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?