# -*- encoding: utf-8 -*- require File.expand_path('../fixtures/classes.rb', __FILE__) describe "String#rjust with length, padding" do it "returns a new string of specified length with self right justified and padded with padstr" do "hello".rjust(20, '1234').should == "123412341234123hello" "".rjust(1, "abcd").should == "a" "".rjust(2, "abcd").should == "ab" "".rjust(3, "abcd").should == "abc" "".rjust(4, "abcd").should == "abcd" "".rjust(6, "abcd").should == "abcdab" "OK".rjust(3, "abcd").should == "aOK" "OK".rjust(4, "abcd").should == "abOK" "OK".rjust(6, "abcd").should == "abcdOK" "OK".rjust(8, "abcd").should == "abcdabOK" end it "pads with whitespace if no padstr is given" do "hello".rjust(20).should == " hello" end it "returns self if it's longer than or as long as the specified length" do "".rjust(0).should == "" "".rjust(-1).should == "" "hello".rjust(4).should == "hello" "hello".rjust(-1).should == "hello" "this".rjust(3).should == "this" "radiology".rjust(8, '-').should == "radiology" end end