diff options
Diffstat (limited to 'spec/ruby/library/matrix/constructor_spec.rb')
| -rw-r--r-- | spec/ruby/library/matrix/constructor_spec.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/spec/ruby/library/matrix/constructor_spec.rb b/spec/ruby/library/matrix/constructor_spec.rb index ae707166cd..026525f36d 100644 --- a/spec/ruby/library/matrix/constructor_spec.rb +++ b/spec/ruby/library/matrix/constructor_spec.rb @@ -1,14 +1,14 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' require 'matrix' describe "Matrix.[]" do it "requires arrays as parameters" do - lambda { Matrix[5] }.should raise_error(TypeError) - lambda { Matrix[nil] }.should raise_error(TypeError) - lambda { Matrix[1..2] }.should raise_error(TypeError) - lambda { Matrix[[1, 2], 3] }.should raise_error(TypeError) + -> { Matrix[5] }.should.raise(TypeError) + -> { Matrix[nil] }.should.raise(TypeError) + -> { Matrix[1..2] }.should.raise(TypeError) + -> { Matrix[[1, 2], 3] }.should.raise(TypeError) end it "creates an empty Matrix with no arguments" do @@ -18,15 +18,13 @@ describe "Matrix.[]" do end it "raises for non-rectangular matrices" do - lambda{ Matrix[ [0], [0,1] ] }.should \ - raise_error(Matrix::ErrDimensionMismatch) - lambda{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \ - raise_error(Matrix::ErrDimensionMismatch) + ->{ Matrix[ [0], [0,1] ] }.should.raise(Matrix::ErrDimensionMismatch) + ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should.raise(Matrix::ErrDimensionMismatch) end it "accepts vector arguments" do a = Matrix[Vector[1, 2], Vector[3, 4]] - a.should be_an_instance_of(Matrix) + a.should.instance_of?(Matrix) a.should == Matrix[ [1, 2], [3, 4] ] end @@ -38,7 +36,7 @@ describe "Matrix.[]" do it "returns a Matrix object" do - Matrix[ [1] ].should be_an_instance_of(Matrix) + Matrix[ [1] ].should.instance_of?(Matrix) end it "can create an nxn Matrix" do @@ -59,7 +57,7 @@ describe "Matrix.[]" do describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub[ [20,30], [40.5, 9] ].should be_an_instance_of(MatrixSub) + MatrixSub[ [20,30], [40.5, 9] ].should.instance_of?(MatrixSub) end end end |
