File tree Expand file tree Collapse file tree
spec/octocatalog-diff/tests/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,10 +19,13 @@ def initialize(options, logger)
1919 # The method to call externally, passing in diffs. This takes the appropriate action
2020 # based on options, which is either to write the result into an output file, or print
2121 # the result on STDOUT. Does not return anything.
22- # @param diffs [OctocatalogDiff::CatalogDiff::Differ] Difference array
22+ # @param diffs [Array<Diffs>] Array of differences
2323 # @param from_dir [String] Directory in which "from" catalog was compiled
2424 # @param to_dir [String] Directory in which "to" catalog was compiled
2525 def printer ( diffs , from_dir = nil , to_dir = nil )
26+ unless diffs . is_a? ( Array )
27+ raise ArgumentError , "printer() expects an array, not #{ diffs . class } "
28+ end
2629 display_opts = @options . merge ( compilation_from_dir : from_dir , compilation_to_dir : to_dir )
2730 diff_text = OctocatalogDiff ::CatalogDiff ::Display . output ( diffs , display_opts , @logger )
2831 if @options [ :output_file ] . nil?
Original file line number Diff line number Diff line change 1414 @diff = JSON . parse ( File . read ( OctocatalogDiff ::Spec . fixture_path ( 'diffs/catalog-1-vs-catalog-2.json' ) ) )
1515 end
1616
17+ it 'should raise an ArgumentError when called with something other than an array' do
18+ testobj = described_class . new ( nil , nil )
19+ expect do
20+ testobj . printer ( :foo )
21+ end . to raise_error ( ArgumentError , 'printer() expects an array, not Symbol' )
22+ end
23+
1724 it 'should write to a file when options output_file is specified' do
1825 begin
1926 # Set up the tempfile to output to.
You can’t perform that action at this time.
0 commit comments