it"returns a slice if both range values begin at the start and are within bounds"do
:symbol.send(@method,1..4).should=="ymbo"
end
it"returns a slice if the first range value begins at the start and the last begins at the end"do
:symbol.send(@method,1..-1).should=="ymbol"
end
it"returns a slice if the first range value begins at the end and the last begins at the end"do
:symbol.send(@method,-4..-1).should=="mbol"
end
end
describe"that is out of bounds"do
it"returns nil if the first range value begins past the end"do
:symbol.send(@method,10..12).shouldbe_nil
end
it"returns a blank string if the first range value is within bounds and the last range value is not"do
:symbol.send(@method,-2..-10).should==""
:symbol.send(@method,2..-10).should==""
end
it"returns nil if the first range value starts from the end and is within bounds and the last value starts from the end and is greater than the length"do
:symbol.send(@method,-10..-12).shouldbe_nil
end
it"returns nil if the first range value starts from the end and is out of bounds and the last value starts from the end and is less than the length"do
:symbol.send(@method,-10..-2).shouldbe_nil
end
end
describe"with Float values"do
it"converts the first value to an Integer"do
:symbol.send(@method,0.5..2).should=="sym"
end
it"converts the last value to an Integer"do
:symbol.send(@method,0..2.5).should=="sym"
end
end
end
describe"with a Range subclass slice"do
it"returns a slice"do
range=SymbolSpecs::MyRange.new(1,4)
:symbol.send(@method,range).should=="ymbo"
end
end
describe"with a Regex slice"do
describe"without a capture index"do
it"returns a string of the match"do
:symbol.send(@method,/[^bol]+/).should=="sym"
end
it"returns nil if the expression does not match"do
:symbol.send(@method,/0-9/).shouldbe_nil
end
it"sets $~ to the MatchData if there is a match"do
:symbol.send(@method,/[^bol]+/)
$~[0].should=="sym"
end
it"does not set $~ if there if there is not a match"do
:symbol.send(@method,/[0-9]+/)
$~.shouldbe_nil
end
it"returns a tainted string if the regexp is tainted"do