Sha256: d9fb0e6d9e9e7d6f357e7503c71f2b69deec2b6f0b77aaf54d556391673829ea

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

module Spackle::Output
  describe Base do
    before do
      @error = spackle_error_fixture
    end

    describe "instance" do
      before do
        @subject = Base.new spackle_error_fixture
      end

      it "should call format_backtrace_line" do
        line_count = spackle_error_fixture.backtrace.size
        @subject.should_receive(:format_backtrace_line).exactly(line_count).times
        @subject.format
      end

      it "should return the formatted output" do
        @subject.stub!(:format_backtrace_line).and_return("foo")
        @subject.format.should == "foo\n" * 3
      end
    end

    describe "instantiating" do
      it "should use Spackle's default error if none specified" do
        Spackle.should_receive(:current_error).and_return(@error)
        Base.new.error.should == @error
      end
    end

    describe "#format class method" do
      before do
        @instance = mock("instance")
      end

      it "should initialize and return formatted lines" do
        Base.should_receive(:new).with(@error).and_return(@instance)
        @instance.should_receive :format
        Base.format @error
      end

      it "should use Spackle's default error if none specified" do
        Base.should_receive(:new).with(@error).and_return(@instance)
        Spackle.should_receive(:current_error).and_return(@error)
        @instance.stub!(:format)
        Base.format
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spackle-0.0.3 spec/spackle/output/base_spec.rb
spackle-0.0.2 spec/spackle/output/base_spec.rb
spackle-0.0.1 spec/spackle/output/base_spec.rb