Created
May 27, 2016 07:21
-
-
Save scudelletti/2d766d512e1e5f58fa66757d783ad65c to your computer and use it in GitHub Desktop.
How to avoid global constant in the specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Wow Coins" do | |
let(:klasz_class) do | |
Class.new do | |
attr_reader :title | |
def initialize(properties) | |
@title = properties[:title] | |
end | |
end | |
end | |
describe "public stuff" do | |
subject { !!defined?(Klasz) } | |
context "when I stub the contant" do | |
before do | |
stub_const("Klasz", klasz_class) | |
end | |
it { is_expected.to be(true) } | |
end | |
context "when I DO NOT stub the contant" do | |
it { is_expected.to be(false) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment