Sha256: cc4c584651e53b5f6e0dbf1623a3e6f044c0517839fe677e019c0b336173b7b9

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

#
# Copyright (c) 2012 RightScale Inc
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

require 'rubygems'
require 'bundler/setup'

require 'flexmock'
require 'rspec'

RSpec.configure do |c|
  c.mock_with(:flexmock)
end

$TESTING = true
$VERBOSE = nil # Disable constant redefined warning

module RightAMQP

  module SpecHelper

    # Setup mocking of logger such that need to override :error and :warning
    # in specs that are expected to require use of these methods
    # Do not mock :exception because that gets eaten by Log::Mixin and results
    # in :error call
    def setup_logger
      @logger = flexmock("logger")
      @logger.should_receive(:level).and_return(:info).by_default
      @logger.should_receive(:error).by_default.and_return { |m| raise m }
      @logger.should_receive(:warning).by_default.and_return { |m| raise m }
      @logger.should_receive(:info).by_default
      @logger.should_receive(:debug).by_default
      RightSupport::Log::Mixin.default_logger = @logger
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
right_amqp-0.3.1 spec/spec_helper.rb
right_amqp-0.3.0 spec/spec_helper.rb
right_amqp-0.2.1 spec/spec_helper.rb
right_amqp-0.2.0 spec/spec_helper.rb