Skip to content

Commit dd02827

Browse files
authored
Merge pull request #70 from antonio/fix-setting-values-in-diff
Add missing []= method
2 parents 3840851 + 65c10b6 commit dd02827

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/octocatalog-diff/api/v1/diff.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def [](i)
4949
@raw[i]
5050
end
5151

52+
# Public: Set an element of the array
53+
# @param [new_value] The value to set it to
54+
def []=(i, new_value)
55+
@raw[i] = new_value
56+
end
57+
5258
# Public: Is this an addition?
5359
# @return [Boolean] True if this is an addition
5460
def addition?

spec/octocatalog-diff/tests/api/v1/diff_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
end
4343
end
4444

45+
describe '#[]=' do
46+
it 'should set values in the array' do
47+
testobj = described_class.new(chg_1)
48+
testobj[3] = 'newer'
49+
expect(testobj.new_value).to eq('newer')
50+
end
51+
end
52+
4553
describe '#diff_type' do
4654
it 'should identify the symbol' do
4755
testobj = described_class.new(chg_2)

0 commit comments

Comments
 (0)