Question : ruby stub_constant
Answered by : mysterious-mantis-2t9yeiqzzhwz
# RSpec - Use stub_const to stub constants.
# When the constant is already defined, the stubbed value will replace the original value for the duration of the example.
FOO = 7
describe "stubbing FOO" do it "can stub FOO with a different value" do stub_const("FOO", 5) FOO.should eq(5) end it "restores the stubbed constant when the example completes" do FOO.should eq(7) end
end
Source : https://relishapp.com/rspec/rspec-mocks/v/2-11/docs/stubbing-constants/stub-defined-constant | Last Update : Thu, 22 Sep 22
Question : ruby constants
Answered by : lior
my_variable = 18 # simple ruby variable
MY_CONSTANT = 25 # ruby constant
Source : | Last Update : Sun, 06 Dec 20