Created
December 9, 2011 19:47
-
-
Save nwjsmith/1452992 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'rspec' | |
describe "why freezing constants isn't cargo-culting" do | |
describe "unfrozen constants" do | |
THAWED_STRING = "Thawed" | |
def bar | |
THAWED_STRING | |
end | |
it "doesn't raise an error when I edit #bar" do | |
expect { bar << ", silly developer" }.to_not raise_error | |
bar.should == "Thawed, silly developer" | |
end | |
end | |
describe "frozen constants" do | |
FROZEN_STRING = "Frozen".freeze | |
def bar | |
FROZEN_STRING | |
end | |
it "throws an error when I edit #bar" do | |
expect { Foo.new.bar << " silly developer" }.to raise_error | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment