Sha256: 6dcb392be46223aa384779b77cce4b2f38185961e998cbd0d72f4355a2a364cc

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
require 'differ/string'

describe Differ::StringDiffer do
  it 'should be automatically mixed into String' do
    expect(String.included_modules).to include(Differ::StringDiffer)
  end

  before(:each) do
    Differ.separator = nil
  end

  describe '#diff' do
    it 'should call Differ#diff' do
      expect(Differ).to receive(:diff).with('TO', 'FROM', "\n").once
      'TO'.diff('FROM')
    end

    it 'should call Differ#diff with Differ.separator' do
      Differ.separator = 'x'
      expect(Differ).to receive(:diff).with('TO', 'FROM', Differ.separator).once
      'TO'.diff('FROM')
    end
  end

  describe '#-' do
    it 'should call Differ#diff' do
      expect(Differ).to receive(:diff).with('TO', 'FROM', "\n").once
      'TO' - 'FROM'
    end

    it 'should call Differ#diff with Differ.separator' do
      Differ.separator = 'x'
      expect(Differ).to receive(:diff).with('TO', 'FROM', Differ.separator).once
      'TO' - 'FROM'
    end
  end
  
  describe '#diff_by_char' do
    it 'should call Differ#diff' do
      expect(Differ).to receive(:diff).with('Othellos', 'hello', '').once
      'Othellos'.diff_by_char('hello')
    end
  end
  
  describe '#diff_by_word' do
    it 'should call Differ#diff' do
      expect(Differ).to receive(:diff).with('Othellos', 'hello', /\b/).once
      'Othellos'.diff_by_word('hello')
    end
  end
  
  describe '#diff_by_line' do
    it 'should call Differ#diff' do
      expect(Differ).to receive(:diff).with('Othellos', 'hello', "\n").once
      'Othellos'.diff_by_line('hello')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ninja-differ-1.0.0 spec/differ/string_spec.rb