Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 33 lines (28 sloc) 0.918 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
require File.join(File.dirname(__FILE__), '..', 'lib', 'tadpole')

describe Array do
  describe '#place' do
    it "should create an Insertion object" do
      [].place('x').should be_kind_of(Insertion)
    end
  end
end

describe Insertion do
  describe '#before' do
    it "should place an object before another" do
      [1, 2].place(3).before(2).should == [1, 3, 2]
      [1, 2].place(3).before(1).should == [3, 1, 2]
      [1, [4], 2].place(3).before(2).should == [1, [4], 3, 2]
    end
  end
  
  describe '#after' do
    it "should place an object after another" do
      [1, 2].place(3).after(2).should == [1, 2, 3]
    end

    it "should place an object after another and its subsections" do
      [1, [2]].place(3).after(1).should == [1, [2], 3]
    end

    it "should not not ignore subsections if ignore_subections=false" do
      [1, [2]].place(3).after(1, false).should == [1, 3, [2]]
    end
  end
end
Something went wrong with that request. Please try again.