# encoding: utf-8 require_relative "../../lib/rubyexts/array" describe Array do describe "#only" do it "should returns the only item in array" do [:first].only.should eql(:first) end it "should raise IndexError if the array has more items" do -> { [1, 2].only }.should raise_error(IndexError) end it "should raise IndexError if the array is empty" do -> { Array.new.only }.should raise_error(IndexError) end end end