spec/ratchetio_spec.rb in ratchetio-0.4.3 vs spec/ratchetio_spec.rb in ratchetio-0.4.4
- old
+ new
@@ -1,12 +1,10 @@
require 'socket'
require 'spec_helper'
describe Ratchetio do
- it 'controller methods'
-
context 'report_exception' do
before(:each) do
configure
Ratchetio.configure do |config|
config.logger = logger_mock
@@ -24,10 +22,23 @@
it 'should report exceptions without person or request data' do
logger_mock.should_receive(:info).with('[Ratchet.io] Sending payload')
Ratchetio.report_exception(@exception)
end
+ it 'should not report anything when disabled' do
+ logger_mock.should_not_receive(:info).with('[Ratchet.io] Sending payload')
+ Ratchetio.configure do |config|
+ config.enabled = false
+ end
+
+ Ratchetio.report_exception(@exception)
+
+ Ratchetio.configure do |config|
+ config.enabled = true
+ end
+ end
+
it 'should report exceptions with request and person data' do
logger_mock.should_receive(:info).with('[Ratchet.io] Sending payload')
request_data = {
:params => { :foo => "bar" },
:url => 'http://localhost/',
@@ -74,9 +85,22 @@
let(:logger_mock) { double("Rails.logger").as_null_object }
it 'should report simple messages' do
logger_mock.should_receive(:info).with('[Ratchet.io] Sending payload')
Ratchetio.report_message("Test message")
+ end
+
+ it 'should not report anything when disabled' do
+ logger_mock.should_not_receive(:info).with('[Ratchet.io] Sending payload')
+ Ratchetio.configure do |config|
+ config.enabled = false
+ end
+
+ Ratchetio.report_message("Test message that should be ignored")
+
+ Ratchetio.configure do |config|
+ config.enabled = true
+ end
end
it 'should report messages with extra data' do
logger_mock.should_receive(:info).with('[Ratchet.io] Sending payload')
Ratchetio.report_message("Test message with extra data", 'debug', :foo => "bar",