Skip to content

Provide a default value (Mock.new) for stub_const.

Created by: stevenharman

Currently you are required to provide a value for the stubbed constant, but there are times that I don't actually care what it is because I'm just going to stub the usage of the constant anyhow. For example:

stub_const('DeathStar', stub)
Starship.stub(:status) { :operational }

This allows you to

stub_const('DeathStar')
Starship.stub(:status) { :operational }

  # or
stub_const('DeathStar').stub(:status) { :operational }

Merge request reports