summaryrefslogtreecommitdiff
path: root/spec/issues_spec.rb
blob: c4542bbdce87a25299a662a6486e497b5e826993 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true

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

  describe "issue #57" do
    it 'should fail with a correct error' do
      expect {
        actual = {:category=>"app.rack.request"}
        expected = {:category=>"rack.middleware", :title=>"Anonymous Middleware"}
        expect(actual).to eq(expected)
      }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
    end
  end
end