test/test_api.rb in rib-1.5.1 vs test/test_api.rb in rib-1.5.2

- old
+ new

@@ -10,11 +10,47 @@ mod = Module.new do define_method meth do "pong_#{meth}" end end - shell = Rib::Shell.dup - shell.use(mod) - shell.new.send(meth).should == "pong_#{meth}" + klass = Rib::Shell.dup + klass.use(mod) + + expect(klass.new.send(meth)).eq "pong_#{meth}" + end + end + + would 'emit a warning whenever result is not a string' do + object = Class.new{ alias_method :inspect, :object_id }.new + + mock(shell).get_input{'object'} + mock(shell).loop_eval('object'){object} + mock(shell).puts("=> #{object.object_id}"){} + mock($stderr).puts(including("#{object.class}#inspect")){} + + shell.loop_once + + ok + end + + describe '#warn' do + would 'append a warning message to warnings' do + shell.warn('test') + + expect(shell.warnings).eq ['test'] + end + end + + describe '#flush_warnings' do + before do + shell.warn('test') + + mock($stderr).puts('rib: test'){} + end + + would 'warn to $stderr from #warnings' do + shell.send(:flush_warnings) + + ok end end end