File tree Expand file tree Collapse file tree
lib/octocatalog-diff/api/v1
spec/octocatalog-diff/tests/api/v1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,8 +22,13 @@ class Diff
2222 # Constructor: Accepts a diff in the traditional array format and stores it.
2323 # @param raw [Array] Diff in the traditional format
2424 def initialize ( raw )
25+ if raw . is_a? ( OctocatalogDiff ::API ::V1 ::Diff )
26+ @raw = raw . raw
27+ return
28+ end
29+
2530 unless raw . is_a? ( Array )
26- raise ArgumentError , ' OctocatalogDiff::API::V1::Diff#initialize expects Array argument'
31+ raise ArgumentError , " OctocatalogDiff::API::V1::Diff#initialize expects Array argument (got #{ raw . class } )"
2732 end
2833 @raw = raw
2934 end
Original file line number Diff line number Diff line change 350350 end
351351
352352 describe '#initialize' do
353+ it 'should set up raw object when called with an instance of itself' do
354+ obj1 = described_class . new ( chg_2 )
355+ testobj = described_class . new ( obj1 )
356+ expect ( testobj . raw ) . to eq ( chg_2 )
357+ end
358+
353359 it 'should raise ArgumentError if called with a non-array' do
354360 expect { described_class . new ( 'foo' ) } . to raise_error ( ArgumentError )
355361 end
You can’t perform that action at this time.
0 commit comments