Sha256: e06e792bf2725e69678e97d8d126fcf52a85f0a1cb525c66aa10e2c9121c1f19

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

require "spec_helper"
require "teabag/console"

describe Guard::Teabag::Runner do

  before do
    Teabag::Console.stub(:new)
  end

  describe "#initialize" do

    it "assigns options" do
      options = {foo: "bar"}
      subject = Guard::Teabag::Runner.new(options)
      expect(subject.instance_variable_get(:@options)).to be(options)
    end

    it "aborts with a message on Teabag::EnvironmentNotFound" do
      Teabag::Console.should_receive(:new).and_raise(Teabag::EnvironmentNotFound)
      Guard::Teabag::Runner.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")
      Guard::Teabag::Runner.new
    end

  end

  describe "#run_all" do

    let(:console) { mock(execute: nil) }

    before do
      subject.console = console
      subject.instance_variable_set(:@options, {foo: "bar"})
    end

    it "calls execute on console" do
      console.should_receive(:execute).with({foo: "bar", baz: "teabag"})
      subject.run_all(baz: "teabag")
    end

  end

  describe "#run" do

    let(:console) { mock(execute: nil) }

    before do
      subject.console = console
      subject.instance_variable_set(:@options, {foo: "bar"})
    end

    it "calls execute on console" do
      files = ["file1", "file2"]
      console.should_receive(:execute).with({foo: "bar", baz: "teabag"}, files)
      subject.run(files, baz: "teabag")
    end

    it "does nothing if there's no paths" do
      console.should_not_receive(:execute)
      subject.run([], baz: "teabag")
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guard-teabag-0.0.2 spec/guard/teabag/runner_spec.rb
guard-teabag-0.0.1 spec/guard/teabag/runner_spec.rb