1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
require "spec_helper"
require "hamster/immutable"
describe Hamster::Immutable do
describe "#immutable?" do
describe "object constructed after its class becomes Immutable" do
class Fixture
include Hamster::Immutable
end
before do
@fixture = Fixture.new
end
it "returns true" do
@fixture.should be_immutable
end
end
describe "object constructed before its class becomes Immutable" do
before do
@fixture = Class.new.new
@fixture.class.instance_eval do
include Hamster::Immutable
end
end
describe "that are not frozen" do
it "returns false" do
@fixture.should_not be_immutable
end
end
describe "that are frozen" do
before do
@fixture.freeze
end
it "returns true" do
@fixture.should be_immutable
end
end
end
end
end
|