diff options
Diffstat (limited to 'spec/ruby/core/struct/struct_spec.rb')
| -rw-r--r-- | spec/ruby/core/struct/struct_spec.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/spec/ruby/core/struct/struct_spec.rb b/spec/ruby/core/struct/struct_spec.rb index 6c1941aed5..1b6a4488ce 100644 --- a/spec/ruby/core/struct/struct_spec.rb +++ b/spec/ruby/core/struct/struct_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' describe "Struct" do it "includes Enumerable" do @@ -21,7 +21,7 @@ describe "Struct anonymous class instance methods" do it "reader method should not interfere with undefined methods" do car = StructClasses::Car.new('Ford', 'Ranger') - lambda { car.something_weird }.should raise_error(NoMethodError) + -> { car.something_weird }.should raise_error(NoMethodError) end it "writer method be a synonym for []=" do @@ -33,6 +33,13 @@ describe "Struct anonymous class instance methods" do car['model'].should == 'F150' car[1].should == 'F150' end + + it "writer methods raise a FrozenError on a frozen struct" do + car = StructClasses::Car.new('Ford', 'Ranger') + car.freeze + + -> { car.model = 'Escape' }.should raise_error(FrozenError) + end end describe "Struct subclasses" do |
