LoginSignup
1
1

More than 5 years have passed since last update.

RSpecでmoduleをテストする

Last updated at Posted at 2014-01-28

モジュールをテストするとき、適当なクラスを作ってそこにincludeした状態をletで使い回したい。というのをこんな感じで書いています。何か他にいい方法があれば教えてください。

describe HogeModule do
  let(:klass) do
    klass = Class.new
    klass.send(:include, HogeModule)
    klass
  end

  # ...
end

Class.newを使うのはこれが初めてかもしれない。

1
1
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
1
1