diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb index 19771dd99572e..193d895247137 100644 --- a/Library/Homebrew/test/requirement_spec.rb +++ b/Library/Homebrew/test/requirement_spec.rb @@ -163,11 +163,7 @@ let(:klass) { self.class.const_get(const) } before do - self.class.const_set(const, Class.new(described_class)) - end - - after do - self.class.send(:remove_const, const) + stub_const const.to_s, Class.new(described_class) end its(:name) { is_expected.to eq("foo") }