Sha256: b4ace5410281e1170cd6ff255041ca53c55040f92937d4e7e2061969338bce9c

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 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 formatter" do
      expect(command).to match %r{-r .*/lib/guard/rspec/formatter.rb -f Guard::RSpec::Formatter}
    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 { allow(RSpec::Core::ConfigurationOptions).to receive(: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

7 entries across 7 versions & 1 rubygems

Version Path
guard-rspec-4.2.6 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.5 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.4 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.3 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.2 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.1 spec/lib/guard/rspec/command_spec.rb
guard-rspec-4.2.0 spec/lib/guard/rspec/command_spec.rb