Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created December 9, 2011 19:47
Show Gist options
  • Save nwjsmith/1452992 to your computer and use it in GitHub Desktop.
Save nwjsmith/1452992 to your computer and use it in GitHub Desktop.
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