spec/sonar/cli_spec.rb in sonar-client-0.0.4 vs spec/sonar/cli_spec.rb in sonar-client-0.0.5

- old
+ new

@@ -35,9 +35,20 @@ it 'parses the nested values in an array' do output = run_command('search sslcert 152a0a633aaf13f02c428ac1a3e672e895512bfd') expect(JSON.parse(output)['collection'].first['details'].first['subject']['ST']).to eq('California') end end + context 'client that returns processed reply with nested json' do + before do + allow_any_instance_of(Sonar::Client).to receive(:search).and_return( + Sonar::Client.new.search(processed: '8.8.8.') + ) + end + it 'parses the nested value as a string' do + output = run_command('search processed 8.8.8.') + expect(JSON.parse(output)['collection'].first['value']['ip']).to eq('8.8.8.8') + end + end end def run_command(args) capture(:stdout) { Sonar::CLI.start(args.split) }.strip end