diff --git a/lib/mqtt.rb b/lib/mqtt.rb index 9c631f6..0ef35e5 100644 --- a/lib/mqtt.rb +++ b/lib/mqtt.rb @@ -20,7 +20,7 @@ module MQTT DEFAULT_SSL_PORT = 8883 # Super-class for other MQTT related exceptions - class Exception < ::Exception + class Exception < StandardError end # A ProtocolException will be raised if there is a diff --git a/spec/mqtt_exception_spec.rb b/spec/mqtt_exception_spec.rb new file mode 100644 index 0000000..389f396 --- /dev/null +++ b/spec/mqtt_exception_spec.rb @@ -0,0 +1,23 @@ +$:.unshift(File.dirname(__FILE__)) + +require 'spec_helper' +require 'mqtt' + +describe MQTT do + + describe "mqtt exceptions" do + it "should be a ruby standard error" do + expect(MQTT::ProtocolException.new).to be_a(StandardError) + expect(MQTT::NotConnectedException.new).to be_a(StandardError) + expect(MQTT::SN::ProtocolException.new).to be_a(StandardError) + end + + it "should be an mqtt error" do + expect(MQTT::ProtocolException.new).to be_a(MQTT::Exception) + expect(MQTT::NotConnectedException.new).to be_a(MQTT::Exception) + expect(MQTT::SN::ProtocolException.new).to be_a(MQTT::Exception) + end + + end + +end