123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Support::HunkGenerator Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rspec-support/lib/rspec/support/hunk_generator.rb

Class Method Summary

Instance Method Summary

Instance Method Details

#actual_lines (private)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 32

def actual_lines
  @actual.split("\n").map! { |e| e.chomp }
end

#build_hunk(piece) (private)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 36

def build_hunk(piece)
  Diff::LCS::Hunk.new(
    expected_lines, actual_lines, piece, context_lines, @file_length_difference
  ).tap do |h|
    @file_length_difference = h.file_length_difference
  end
end

#context_lines (private)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 44

def context_lines
  3
end

#diffs (private)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 24

def diffs
  Diff::LCS.diff(expected_lines, actual_lines)
end

#expected_lines (private)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 28

def expected_lines
  @expected.split("\n").map! { |e| e.chomp }
end

#hunks

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/hunk_generator.rb', line 15

def hunks
  @file_length_difference = 0
  @hunks ||= diffs.map do |piece|
    build_hunk(piece)
  end
end