Testing modules in RSpec

The rad way =>

let(:dummy_class) { Class.new { include ModuleToBeTested } }

Alternatively you can extend the test class with your module:

let(:dummy_class) { Class.new { extend ModuleToBeTested } }

Using ‘let’ is better than using an instance variable to define the dummy class in the before(:each)

When to use RSpec let()?

Leave a Comment