Sha256: 6d7be40bdf67837fa189fe580e097a3fc2b611385d70c1a9c15f8e69967dfbd1

Contents?: true

Size: 1.6 KB

Versions: 11

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  module Logging

    describe Debug do

      let(:described) { Vedeu::Logging::Debug }

      before do
        File.stubs(:open).with('/tmp/profile.html', 'w').returns(:some_code)
      end

      describe '.debug' do
        let(:_binding) {}
        let(:_obj)     {}

        subject { described.debug(_binding, _obj) }

        context 'when pry is available' do
          # @todo Add more tests.
        end

        context 'when pry is not available' do
          before { Vedeu.stubs(:requires_gem!).raises(Vedeu::Error::Fatal) }

          it { proc { subject }.must_raise(Vedeu::Error::Fatal) }
        end
      end

      describe '.profile' do
        let(:filename)  { 'profile.html' }
        let(:some_code) { :some_code }

        subject { described.profile(filename) { some_code } }

        context 'when ruby-prof is available' do
          before { Vedeu.stubs(:requires_gem!).returns(true) }

          context 'when the block is not given' do
            subject { described.profile(filename) }

            it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
          end

          context 'when the block is given' do
            subject { described.profile(filename) { some_code } }

            it { subject.must_equal(some_code) }
          end
        end

        context 'when ruby-prof is not available' do
          before { Vedeu.stubs(:requires_gem!).raises(Vedeu::Error::Fatal) }

          it { proc { subject }.must_raise(Vedeu::Error::Fatal) }
        end
      end

    end # Debug

  end # Logging

end # Vedeu

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vedeu-0.8.12 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.10 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.9 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.8 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.7 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.6 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.5 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.4 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.3 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.2 test/lib/vedeu/logging/debug_test.rb
vedeu-0.8.1 test/lib/vedeu/logging/debug_test.rb