Sha256: 53c06f6e5d0c9f585fb830f1352d2d0d4fe790e3e705bbba51f2b9a643c2c1a8

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

require 'gorgon/crash_reporter'

describe "CrashReporter" do
  let(:exchange) { double("GorgonBunny Exchange", :publish => nil) }
  let(:info) { {
      :out_file => "stdout_file", :err_file => "stderr_file", :footer_text => "Text"
    } }

  let(:container_class) do
    Class.new do
      extend(CrashReporter)
    end
  end

  describe "#report_crash" do
    it "tails output file to get last few lines and cat err file to get all lines" do
      container_class.should_receive(:'`').once.
        with(/tail.*stdout_file/).and_return ""
      container_class.should_receive(:'`').once.
        with(/cat.*stderr_file/).and_return ""
      container_class.report_crash exchange, info
    end

    it "calls send_crash_message" do
      container_class.stub(:'`').and_return "stdout text", "stderr text "
      container_class.should_receive(:send_crash_message).with(exchange, "stdout text", "stderr text Text")
      container_class.report_crash exchange, info
    end

    it "returns last lines of output from stderr message and footer text" do
      container_class.stub(:'`').and_return "stdout text", "stderr text "
      container_class.stub(:send_crash_message)
      result = container_class.report_crash exchange, info
      result.should == "stdout text\nstderr text Text"
    end
  end

  describe "#send_crash_message" do
    it "sends message with output and errors from syncer using reply_exchange " do
      reply = {:type => :crash, :hostname => Socket.gethostname, :stdout => "some output",
        :stderr => "some errors"}
      exchange.should_receive(:publish).with(Yajl::Encoder.encode(reply))
      container_class.send_crash_message exchange, "some output", "some errors"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gorgon-0.11.0 spec/crash_reporter_spec.rb
gorgon-0.10.5 spec/crash_reporter_spec.rb
gorgon-0.10.4 spec/crash_reporter_spec.rb
gorgon-0.10.3 spec/crash_reporter_spec.rb
gorgon-0.10.2 spec/crash_reporter_spec.rb
gorgon-0.10.1 spec/crash_reporter_spec.rb
gorgon-0.10.0 spec/crash_reporter_spec.rb
gorgon-0.9.0 spec/crash_reporter_spec.rb
gorgon-0.8.4 spec/crash_reporter_spec.rb
gorgon-0.8.3 spec/crash_reporter_spec.rb
gorgon-0.8.2 spec/crash_reporter_spec.rb
gorgon-0.8.1 spec/crash_reporter_spec.rb
gorgon-0.8.0 spec/crash_reporter_spec.rb
gorgon-0.7.1 spec/crash_reporter_spec.rb
gorgon-0.7.0 spec/crash_reporter_spec.rb