Sha256: e616c29f5581ce8b25838aa687a696fb9270b8c9e3cc172c0c13e64245f1eb0f

Contents?: true

Size: 1.58 KB

Versions: 11

Compression:

Stored size: 1.58 KB

Contents

require "spec_helper"
require "teabag/command_line"
require "teabag/console"

describe Teabag::CommandLine do

  describe "#initialize" do

    let(:console) { mock(execute: false) }
    let(:parser) { mock(parse!: ["file1", "file2"]) }

    before do
      Teabag::CommandLine.any_instance.stub(:abort)
      Teabag::Console.stub(:new).and_return(console)
      Teabag::CommandLine.any_instance.stub(:opt_parser).and_return(parser)
    end

    it "assigns @options" do
      instance = Teabag::CommandLine.new
      expect(instance.instance_variable_get(:@options)).to eq({})
    end

    it "assigns @files" do
      instance = Teabag::CommandLine.new
      expect(instance.instance_variable_get(:@files)).to eq(["file1", "file2"])
    end

    it "aborts with a message on Teabag::EnvironmentNotFound" do
      Teabag::Console.should_receive(:new).and_raise(Teabag::EnvironmentNotFound)
      Teabag::CommandLine.any_instance.should_receive(:abort)
      STDOUT.should_receive(:print).with("Unable to load Teabag environment in {spec/teabag_env.rb, test/teabag_env.rb, teabag_env.rb}.\n")
      STDOUT.should_receive(:print).with("Consider using -r path/to/teabag_env\n")
      Teabag::CommandLine.new
    end

    it "executes using Teabag::Console" do
      Teabag::Console.should_receive(:new).with({}, ["file1", "file2"])
      console.should_receive(:execute)
      Teabag::CommandLine.new
    end

    it "aborts if Teabag::Console fails" do
      Teabag::CommandLine.any_instance.should_receive(:abort)
      console.should_receive(:execute).and_return(true)
      Teabag::CommandLine.new
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
teabag-0.7.3 spec/teabag/command_line_spec.rb
teabag-0.7.2 spec/teabag/command_line_spec.rb
teabag-0.7.1 spec/teabag/command_line_spec.rb
teabag-0.7.0 spec/teabag/command_line_spec.rb
teabag-0.6.0 spec/teabag/command_line_spec.rb
teabag-0.5.5 spec/teabag/command_line_spec.rb
teabag-0.5.4 spec/teabag/command_line_spec.rb
teabag-0.5.3 spec/teabag/command_line_spec.rb
teabag-0.5.2 spec/teabag/command_line_spec.rb
teabag-0.5.1 spec/teabag/command_line_spec.rb
teabag-0.5.0 spec/teabag/command_line_spec.rb