summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module/attr_accessor_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module/attr_accessor_spec.rb')
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/ruby/core/module/attr_accessor_spec.rb b/spec/ruby/core/module/attr_accessor_spec.rb
index e6a6ac7b66..ba5289cbea 100644
--- a/spec/ruby/core/module/attr_accessor_spec.rb
+++ b/spec/ruby/core/module/attr_accessor_spec.rb
@@ -33,7 +33,20 @@ describe "Module#attr_accessor" do
attr_accessor :spec_attr_accessor
end
- -> { true.spec_attr_accessor = "a" }.should raise_error(RuntimeError)
+ -> { true.spec_attr_accessor = "a" }.should raise_error(FrozenError)
+ end
+
+ it "raises FrozenError if the receiver if frozen" do
+ c = Class.new do
+ attr_accessor :foo
+ end
+ obj = c.new
+ obj.foo = 1
+ obj.foo.should == 1
+
+ obj.freeze
+ -> { obj.foo = 42 }.should raise_error(FrozenError)
+ obj.foo.should == 1
end
it "converts non string/symbol names to strings using to_str" do