Sha256: d5f44e5ee06ec58df6469a08ae0d90f1ac9224c0086bd89e1f78c7c112b9ea72

Contents?: true

Size: 1.01 KB

Versions: 72

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'r10k/action/visitor'
require 'r10k/logging'

describe R10K::Action::Visitor do
  let(:visitor_class) do
    Class.new do
      include R10K::Action::Visitor
      include R10K::Logging
      attr_accessor :trace

      def visit_error(other)
        raise ArgumentError, "no soup for you"
      end
    end
  end

  subject { visitor_class.new }

  it "dispatches visit invocations to the type specific method" do
    expect(subject).to receive(:visit_sym).with(:hi)
    subject.visit(:sym, :hi)
  end

  describe "when a visit_ method raises an error" do

    [true, false].each do |trace|
      msg = trace ? "a" : "no"
      it "logs the error with #{msg} backtrace when trace is #{trace}" do
        subject.trace = trace
        expect(R10K::Errors::Formatting).to(
          receive(:format_exception).with(instance_of(ArgumentError), trace)
        ).and_return("errmsg")
        expect(subject.logger).to receive(:error).with('errmsg')
        subject.visit(:error, :hi)
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 2 rubygems

Version Path
r10k-3.15.0 spec/unit/action/visitor_spec.rb
akerl-r10k-3.14.2.1 spec/unit/action/visitor_spec.rb
r10k-3.14.2 spec/unit/action/visitor_spec.rb
r10k-3.14.1 spec/unit/action/visitor_spec.rb
r10k-3.14.0 spec/unit/action/visitor_spec.rb
r10k-3.13.0 spec/unit/action/visitor_spec.rb
r10k-3.12.1 spec/unit/action/visitor_spec.rb
r10k-3.12.0 spec/unit/action/visitor_spec.rb
r10k-3.11.0 spec/unit/action/visitor_spec.rb
r10k-3.10.0 spec/unit/action/visitor_spec.rb
r10k-3.9.3 spec/unit/action/visitor_spec.rb
r10k-3.9.2 spec/unit/action/visitor_spec.rb
r10k-3.9.1 spec/unit/action/visitor_spec.rb
r10k-3.9.0 spec/unit/action/visitor_spec.rb
r10k-3.8.0 spec/unit/action/visitor_spec.rb
r10k-3.7.0 spec/unit/action/visitor_spec.rb
r10k-3.6.0 spec/unit/action/visitor_spec.rb
r10k-2.6.9 spec/unit/action/visitor_spec.rb
r10k-3.5.2 spec/unit/action/visitor_spec.rb
r10k-3.5.1 spec/unit/action/visitor_spec.rb