diff options
author | Austin Ziegler <austin@zieglers.ca> | 2019-01-28 00:42:50 -0500 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2019-02-01 22:25:37 -0500 |
commit | a798f6f1dc5d41aceb236ea0aeaa113c8dc89c92 (patch) | |
tree | d9f368b89273969d87f4f5b640d855c7336f453e /spec | |
parent | 45ea1b30c7de0ad840f72afb82fd41eb2b9590db (diff) | |
download | diff-lcs-a798f6f1dc5d41aceb236ea0aeaa113c8dc89c92.tar.gz |
Reintroduce Diff::LCS::Change#to_ary
- This required some level of code remediation in the main library, but all
tests now pass:
- Patchsets are now internally flattened one level explicitly, rather than
using Array#flatten. This ensures that only the outer patchset array is
flattened.
Fixes #48.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/change_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/change_spec.rb b/spec/change_spec.rb index b5ad0cb..b8d3443 100644 --- a/spec/change_spec.rb +++ b/spec/change_spec.rb @@ -62,4 +62,28 @@ describe Diff::LCS::Change do it { should_not be_finished_a } it { should be_finished_b } end + + describe 'as array' do + it 'should be converted' do + action, position, element = described_class.new('!', 0, 'element') + expect(action).to eq '!' + expect(position).to eq 0 + expect(element).to eq 'element' + end + end +end + +describe Diff::LCS::ContextChange do + describe 'as array' do + it 'should be converted' do + action, (old_position, old_element), (new_position, new_element) = + described_class.new('!', 1, 'old_element', 2, 'new_element') + + expect(action).to eq '!' + expect(old_position).to eq 1 + expect(old_element).to eq 'old_element' + expect(new_position).to eq 2 + expect(new_element).to eq 'new_element' + end + end end |