Sha256: 874e354e226ba480668918bd75c56f95211b6ea9c977b79265234bc3b3f6948c

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
require 'launchy'

describe Guard::RSpec::Command do
  let(:options) { { } }
  let(:paths) { %w[path1 path2] }
  let(:command) { Guard::RSpec::Command.new(paths, options) }

  describe '.initialize' do

    it "sets paths at the end" do
      expect(command).to match /path1 path2$/
    end

    it "sets custom failure exit code" do
      expect(command).to match /--failure-exit-code 2/
    end

    it "sets notifier formatter" do
      expect(command).to match %r{-r .*/lib/guard/rspec/formatters/notifier.rb -f Guard::RSpec::Formatters::Notifier}
    end

    it "sets focuser formatter" do
      expect(command).to match %r{-r .*/lib/guard/rspec/formatters/focuser.rb -f Guard::RSpec::Formatters::Focuser}
    end

    context "with custom cmd" do
      let(:options) { { cmd: 'rspec -t ~slow' } }

      it "uses custom cmd" do
        expect(command).to match  /^rspec -t ~slow/
      end
    end

    context "with RSpec defined formatter" do
      let(:formatters) { [['doc','output']] }
      before { RSpec::Core::ConfigurationOptions.stub(:new) { double(parse_options: { formatters: formatters }) } }

      it "uses them" do
        expect(command).to match %r{-f doc -o output}
      end
    end

    context "with no RSpec defined formatter" do
      it "sets default progress formatter" do
        expect(command).to match %r{-f progress}
      end
    end

    context "with formatter in cmd" do
      let(:options) { { cmd: 'rspec -f doc' } }

      it "sets no other formatters" do
        expect(command).to match %r{-f doc}
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
guard-rspec-4.0.4 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.0.3 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.0.2 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.0.1 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.0.0 spec/lib/guard/rspec/command_spec.rb