Sha256: 18a1ea35860d75580d716dd54caa87160023fbdfc07aa6c2a53985e1325e4c1d

Contents?: true

Size: 1.21 KB

Versions: 212

Compression:

Stored size: 1.21 KB

Contents

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

require 'spec_helper'

describe "Diff::LCS Issues" do
  include Diff::LCS::SpecHelper::Matchers

  describe 'issue #1' do
    shared_examples 'handles simple diffs' do |s1, s2, forward_diff|
      before do
        @diff_s1_s2 = Diff::LCS.diff(s1, s2)
      end

      it 'creates the correct diff' do
        expect(change_diff(forward_diff)).to eq(@diff_s1_s2)
      end

      it 'creates the correct patch s1->s2' do
        expect(Diff::LCS.patch(s1, @diff_s1_s2)).to eq(s2)
      end

      it 'creates the correct patch s2->s1' do
        expect(Diff::LCS.patch(s2, @diff_s1_s2)).to eq(s1)
      end
    end

    describe 'string' do
      it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
        [ [ '+', 0, 'b' ],
          [ '+', 1, 'X' ] ],
      ]
      it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
        [ [ '-', 0, 'b' ],
          [ '-', 1, 'X' ] ],
      ]
    end

    describe 'array' do
      it_has_behavior 'handles simple diffs', %w(a X), %w(b X a X), [
        [ [ '+', 0, 'b' ],
          [ '+', 1, 'X' ] ],
      ]
      it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
        [ [ '-', 0, 'b' ],
          [ '-', 1, 'X' ] ],
      ]
    end
  end
end

Version data entries

212 entries across 193 versions & 54 rubygems

Version Path
husc-0.2.1 vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb
husc-0.2.0 vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb
husc-0.1.1 vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb
husc-0.1.0 vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/diff-lcs-1.3/spec/issues_spec.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
tdiary-5.1.0 vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
spec_fill-0.1.2 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
genkaio-0.0.2 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/issues_spec.rb
genkaio-0.0.2 vendor/bundle/ruby/2.7.0/gems/diff-lcs-1.3/spec/issues_spec.rb
genkaio-0.0.1 vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.3/spec/issues_spec.rb
spec_fill-0.1.1 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
spec_fill-0.1.0 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/diff-lcs-1.3/spec/issues_spec.rb