diff --git a/lib/volt/tasks/dispatcher.rb b/lib/volt/tasks/dispatcher.rb index c95adff3..09cc52e3 100644 --- a/lib/volt/tasks/dispatcher.rb +++ b/lib/volt/tasks/dispatcher.rb @@ -148,9 +148,23 @@ def dispatch_in_thread(channel, message) promise.then do |result| reply = EJSON.stringify(['response', callback_id, result, nil, cookies]) channel.send_string_message(reply) + # NOTE: On success the method #send_string_message is called above. + # In some specs the method #send_message is stubbed instead. + # Because this is within a promise the RSpec error is trapped and the + # fail block below is called. This results in green tests that should be red. finish.call end.fail do |error| + # NOTE: This next chunk of code should dump to the CI output when the above + # situation triggers. It's what would normally cause the tests to fail. + if error.is_a? RSpec::Mocks::MockExpectationError + puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!" + p error.class + p error + pp error.backtrace + puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!" + end + finish.call(error) # Convert the error into a string so it can be serialized. error_str = "#{error.class.to_s}: #{error.to_s}" diff --git a/spec/tasks/dispatcher_spec.rb b/spec/tasks/dispatcher_spec.rb index 9b4d6956..86634428 100644 --- a/spec/tasks/dispatcher_spec.rb +++ b/spec/tasks/dispatcher_spec.rb @@ -67,7 +67,12 @@ def post(*args) it 'should log an info message before and after the dispatch' do channel = double('channel') + # NOTE: This method stub is incorrect. We should be stubbing #send_string_message + # See line 150 in lib/volt/tasks/dispatcher.rb allow(channel).to receive(:send_message).with('response', 0, 'yes it works', nil) + + # NOTE: This is what I think the stub needs to be. + #allow(channel).to receive(:send_string_message).with(any_args) expect(Volt.logger).to receive(:log_dispatch) dispatcher.dispatch(channel, [0, 'TestTask', :allowed_method, {}, ' it', ' works']) @@ -76,7 +81,12 @@ def post(*args) it 'should let you set a cookie' do channel = double('channel') + # NOTE: This method stub is incorrect. We should be stubbing #send_string_message + # See line 150 in lib/volt/tasks/dispatcher.rb allow(channel).to receive(:send_message).with('response', 0, 'yes it works', {something:"awesome"}) + + # NOTE: This is what I think the stub needs to be. + #allow(channel).to receive(:send_string_message).with(any_args) expect(Volt.logger).to receive(:log_dispatch) dispatcher.dispatch(channel, [0, 'TestTask', :set_cookie, {}])