Sha256: 17b1cb1d58ad6465c25e042314d9e618859991f471f5b3b4aef96c97b455f509

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Insertion do
  describe "#before" do
    it "places an object before another" do
      expect([1, 2].place(3).before(2)).to eq [1, 3, 2]
      expect([1, 2].place(3).before(1)).to eq [3, 1, 2]
      expect([1, [4], 2].place(3).before(2)).to eq [1, [4], 3, 2]
    end
  end

  describe "#after" do
    it "places an object after another" do
      expect([1, 2].place(3).after(2)).to eq [1, 2, 3]
    end

    it "no longer places an object after another and its subsections (0.6)" do
      expect([1, [2]].place(3).after(1)).to eq [1, 3, [2]]
    end

    it "places an array after an object" do
      expect([1, 2, 3].place([4]).after(1)).to eq [1, [4], 2, 3]
    end
  end

  describe "#before_any" do
    it "places an object before another anywhere inside list (including sublists)" do
      expect([1, 2, [3]].place(4).before_any(3)).to eq [1, 2, [4, 3]]
    end
  end

  describe "#after_any" do
    it "places an object after another anywhere inside list (including sublists)" do
      expect([1, 2, [3]].place(4).after_any(3)).to eq [1, 2, [3, 4]]
    end
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/spec/core_ext/insertion_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/spec/core_ext/insertion_spec.rb
yard-0.9.5 spec/core_ext/insertion_spec.rb
yard-0.9.4 spec/core_ext/insertion_spec.rb
yard-0.9.3 spec/core_ext/insertion_spec.rb
yard-0.9.2 spec/core_ext/insertion_spec.rb
yard-0.9.1 spec/core_ext/insertion_spec.rb
yard-0.9.0 spec/core_ext/insertion_spec.rb