File: tdiff_spec.rb

package info (click to toggle)
ruby-tdiff 0.3.3-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 172 kB
  • sloc: ruby: 266; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (2)
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
34
require 'spec_helper'
require 'tdiff_examples'

require 'tdiff/tdiff'

describe TDiff do
  include Helpers::Trees

  it_should_behave_like 'TDiff', :tdiff

  it "should detect when the order of children has changed" do
    changes = @tree.tdiff(@changed_order).to_a

    expect(changes.length).to eq(6)

    expect(changes[0][0]).to eq(' ')
    expect(changes[0][1]).to eq(@tree)

    expect(changes[1][0]).to eq('-')
    expect(changes[1][1]).to eq(@tree.children[0])

    expect(changes[2][0]).to eq(' ')
    expect(changes[2][1]).to eq(@tree.children[1])

    expect(changes[3][0]).to eq('+')
    expect(changes[3][1]).to eq(@changed_order.children[1])

    expect(changes[4][0]).to eq(' ')
    expect(changes[4][1]).to eq(@tree.children[1].children[0])

    expect(changes[5][0]).to eq(' ')
    expect(changes[5][1]).to eq(@tree.children[1].children[1])
  end
end