Sha256: 6e7199bc98fa8a95ff6e30f84dc3112a17b6dc92dc1b75149312596cfd00dc9f

Contents?: true

Size: 1.31 KB

Versions: 87

Compression:

Stored size: 1.31 KB

Contents

# -*- ruby encoding: utf-8 -*-

require 'spec_helper'

describe "Diff::LCS.diff" do
  include Diff::LCS::SpecHelper::Matchers

  it "should correctly diff seq1 to seq2" do
    diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
    change_diff(correct_forward_diff).should == diff_s1_s2
  end

  it "should correctly diff seq2 to seq1" do
    diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
    change_diff(correct_backward_diff).should == diff_s2_s1
  end

  it "should correctly diff against an empty sequence" do
    diff = Diff::LCS.diff(word_sequence, [])
    correct_diff = [
      [ [ '-', 0, 'abcd'           ],
        [ '-', 1, 'efgh'           ],
        [ '-', 2, 'ijkl'           ],
        [ '-', 3, 'mnopqrstuvwxyz' ] ]
    ]

    change_diff(correct_diff).should == diff

    diff = Diff::LCS.diff([], word_sequence)
    correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
    change_diff(correct_diff).should == diff
  end

  it "should correctly diff 'xx' and 'xaxb'" do
    left = 'xx'
    right = 'xaxb'
    Diff::LCS.patch(left, Diff::LCS.diff(left, right)).should == right
  end

  it "should return an empty diff with (hello, hello)" do
    Diff::LCS.diff(hello, hello).should == []
  end

  it "should return an empty diff with (hello_ary, hello_ary)" do
    Diff::LCS.diff(hello_ary, hello_ary).should == []
  end
end

Version data entries

87 entries across 83 versions & 34 rubygems

Version Path
geminfo-0.1.0 path/gems/diff-lcs-1.2.5/spec/diff_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
dxruby_rp5-0.0.4 spec/vendor/diff-lcs-1.2.5/spec/diff_spec.rb
whos_dated_who-0.1.0 vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
whos_dated_who-0.0.1 vendor/bundle/gems/diff-lcs-1.2.5/spec/diff_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
dxruby_rp5-0.0.3 spec/vendor/diff-lcs-1.2.5/spec/diff_spec.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
dxruby_rp5-0.0.2 spec/vendor/diff-lcs-1.2.5/spec/diff_spec.rb
dxruby_rp5-0.0.1 spec/vendor/diff-lcs-1.2.5/spec/diff_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/diff-lcs-1.2.5/spec/diff_spec.rb
diff-lcs-1.2.5 spec/diff_spec.rb