Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use frozen_object_error_class

  • Loading branch information...
commit f0368998fa00bd4195b34950c15e001e7f767bb0 1 parent d8c673b
@jfirebaugh jfirebaugh authored brixen committed
Showing with 17 additions and 49 deletions.
  1. +6 −18 core/kernel/freeze_spec.rb
  2. +11 −31 core/module/freeze_spec.rb
View
24 core/kernel/freeze_spec.rb
@@ -30,23 +30,11 @@
end
end
- ruby_version_is "" ... "1.9" do
- it "causes mutative calls to raise TypeError" do
- o = Class.new do
- def mutate; @foo = 1; end
- end.new
- o.freeze
- lambda {o.mutate}.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "1.9" do
- it "causes mutative calls to raise RuntimeError" do
- o = Class.new do
- def mutate; @foo = 1; end
- end.new
- o.freeze
- lambda {o.mutate}.should raise_error(RuntimeError)
- end
+ it "causes mutative calls to raise an error" do
+ o = Class.new do
+ def mutate; @foo = 1; end
+ end.new
+ o.freeze
+ lambda {o.mutate}.should raise_error(frozen_object_error_class)
end
end
View
42 core/module/freeze_spec.rb
@@ -2,39 +2,19 @@
require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#freeze" do
- ruby_version_is ""..."1.9" do
- it "prevents further modifications to self" do
- m = Module.new.freeze
- m.frozen?.should == true
+ it "prevents further modifications to self" do
+ m = Module.new.freeze
+ m.frozen?.should == true
- # Does not raise
- class << m; end
+ # Does not raise
+ class << m; end
- lambda {
- class << m
- def test() "test" end
- end
- }.should raise_error(TypeError)
+ lambda {
+ class << m
+ def test() "test" end
+ end
+ }.should raise_error(frozen_object_error_class)
- lambda { def m.test() "test" end }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "1.9" do
- it "prevents further modifications to self" do
- m = Module.new.freeze
- m.frozen?.should == true
-
- # Does not raise
- class << m; end
-
- lambda {
- class << m
- def test() "test" end
- end
- }.should raise_error(RuntimeError)
-
- lambda { def m.test() "test" end }.should raise_error(RuntimeError)
- end
+ lambda { def m.test() "test" end }.should raise_error(frozen_object_error_class)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.